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