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

Function RM_ZsetRem

app/redis-6.2.6/src/module.c:2712–2722  ·  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

2710 *
2711 * Empty keys will be handled correctly by doing nothing. */
2712int RM_ZsetRem(RedisModuleKey *key, RedisModuleString *ele, int *deleted) {
2713 if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR;
2714 if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR;
2715 if (key->value != NULL && zsetDel(key->value,ele->ptr)) {
2716 if (deleted) *deleted = 1;
2717 moduleDelKeyIfEmpty(key);
2718 } else {
2719 if (deleted) *deleted = 0;
2720 }
2721 return REDISMODULE_OK;
2722}
2723
2724/* On success retrieve the double score associated at the sorted set element
2725 * 'ele' and returns REDISMODULE_OK. Otherwise REDISMODULE_ERR is returned

Callers

nothing calls this directly

Calls 2

zsetDelFunction · 0.85
moduleDelKeyIfEmptyFunction · 0.85

Tested by

no test coverage detected