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. */
| 2316 | * |
| 2317 | * If the key pointer is NULL or the key is empty, zero is returned. */ |
| 2318 | size_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). |
nothing calls this directly
no test coverage detected