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

Function RM_ZsetRem

src/module.cpp:2800–2810  ·  view source on GitHub ↗

Remove the specified element from the sorted set. * The function returns REDISMODULE_OK on success, and REDISMODULE_ERR * on one of the following conditions: * * * The key was not opened for writing. * * The key is of the wrong type. * * The return value does NOT indicate the fact the element was really * removed (since it existed) or not, just if the function was executed * with success.

Source from the content-addressed store, hash-verified

2798 *
2799 * Empty keys will be handled correctly by doing nothing. */
2800int RM_ZsetRem(RedisModuleKey *key, RedisModuleString *ele, int *deleted) {
2801 if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR;
2802 if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR;
2803 if (key->value != NULL && zsetDel(key->value,szFromObj(ele))) {
2804 if (deleted) *deleted = 1;
2805 moduleDelKeyIfEmpty(key);
2806 } else {
2807 if (deleted) *deleted = 0;
2808 }
2809 return REDISMODULE_OK;
2810}
2811
2812/* On success retrieve the double score associated at the sorted set element
2813 * 'ele' and returns REDISMODULE_OK. Otherwise REDISMODULE_ERR is returned

Callers

nothing calls this directly

Calls 3

zsetDelFunction · 0.85
szFromObjFunction · 0.85
moduleDelKeyIfEmptyFunction · 0.85

Tested by

no test coverage detected