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

Function RM_ValueLength

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

2316 *
2317 * If the key pointer is NULL or the key is empty, zero is returned. */
2318size_t RM_ValueLength(RedisModuleKey *key) {
2319 if (key == NULL || key->value == NULL) return 0;
2320 switch(key->value->type) {
2321 case OBJ_STRING: return stringObjectLen(key->value);
2322 case OBJ_LIST: return listTypeLength(key->value);
2323 case OBJ_SET: return setTypeSize(key->value);
2324 case OBJ_ZSET: return zsetLength(key->value);
2325 case OBJ_HASH: return hashTypeLength(key->value);
2326 case OBJ_STREAM: return streamLength(key->value);
2327 default: return 0;
2328 }
2329}
2330
2331/* If the key is open for writing, remove it, and setup the key to
2332 * 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