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. */
| 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. */ |
| 2564 | int 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 |
nothing calls this directly
no test coverage detected