MCPcopy Create free account
hub / github.com/F-Stack/f-stack / RM_ListPush

Function RM_ListPush

app/redis-6.2.6/src/module.c:2564–2571  ·  view source on GitHub ↗

Push an element into a list, on head or tail depending on 'where' argument. * If the key pointer is about an empty key opened for writing, the key * is created. On error (key opened for read-only operations or of the wrong * type) REDISMODULE_ERR is returned, otherwise REDISMODULE_OK is returned. */

Source from the content-addressed store, hash-verified

2562 * is created. On error (key opened for read-only operations or of the wrong
2563 * type) REDISMODULE_ERR is returned, otherwise REDISMODULE_OK is returned. */
2564int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) {
2565 if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR;
2566 if (key->value && key->value->type != OBJ_LIST) return REDISMODULE_ERR;
2567 if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST);
2568 listTypePush(key->value, ele,
2569 (where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL);
2570 return REDISMODULE_OK;
2571}
2572
2573/* Pop an element from the list, and returns it as a module string object
2574 * that the user should be free with RM_FreeString() or by enabling

Callers

nothing calls this directly

Calls 2

moduleCreateEmptyKeyFunction · 0.85
listTypePushFunction · 0.85

Tested by

no test coverage detected