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

Function RM_ValueLength

src/module.cpp:2402–2413  ·  view source on GitHub ↗

Return the length of the value associated with the key. * For strings this is the length of the string. For all the other types * is the number of elements (just counting keys for hashes). * * If the key pointer is NULL or the key is empty, zero is returned. */

Source from the content-addressed store, hash-verified

2400 *
2401 * If the key pointer is NULL or the key is empty, zero is returned. */
2402size_t RM_ValueLength(RedisModuleKey *key) {
2403 if (key == NULL || key->value == NULL) return 0;
2404 switch(key->value->type) {
2405 case OBJ_STRING: return stringObjectLen(key->value);
2406 case OBJ_LIST: return listTypeLength(key->value);
2407 case OBJ_SET: return setTypeSize(key->value);
2408 case OBJ_ZSET: return zsetLength(key->value);
2409 case OBJ_HASH: return hashTypeLength(key->value);
2410 case OBJ_STREAM: return streamLength(key->value);
2411 default: return 0;
2412 }
2413}
2414
2415/* If the key is open for writing, remove it, and setup the key to
2416 * accept new writes as an empty key (that will be created on demand).

Callers

nothing calls this directly

Calls 6

stringObjectLenFunction · 0.85
listTypeLengthFunction · 0.85
setTypeSizeFunction · 0.85
zsetLengthFunction · 0.85
hashTypeLengthFunction · 0.85
streamLengthFunction · 0.85

Tested by

no test coverage detected