HLEN key
Return the number of entries (fields) contained in the hash stored at the key. If the specified key does not exist, 0 is returned assuming an empty hash.
TIME COMPLEXITY: O(1)
RETURN VALUE: It returns an integer value number of entries.
Syntax:
HLEN KEY_NAME
Example 1: When the key is present.
redis:6379> HSET myhash field2 100(integer) 1redis:6379> HSET myhash field 200(integer) 1redis:6379> HLEN myhash(integer) 2
Output
2
Example 2: When the key is not present.
redis:6379> HLEN myhashkey(integer) 0
Output
0
No comments:
Post a Comment