MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / RM_ListPush

Function RM_ListPush

src/module.cpp:2652–2659  ·  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

2650 * is created. On error (key opened for read-only operations or of the wrong
2651 * type) REDISMODULE_ERR is returned, otherwise REDISMODULE_OK is returned. */
2652int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) {
2653 if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR;
2654 if (key->value && key->value->type != OBJ_LIST) return REDISMODULE_ERR;
2655 if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST);
2656 listTypePush(key->value, ele,
2657 (where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL);
2658 return REDISMODULE_OK;
2659}
2660
2661/* Pop an element from the list, and returns it as a module string object
2662 * 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