SRANDMEMBER key
Return a random element from a Set, without removing the element. If the Set is empty or the key does not exist, a nil object is returned.
TIME COMPLEXITY: O(1)
The SPOP command does similar work but the returned element is popped (removed) from the Set.
RETURN VALUE: Bulk reply
Syntax:
SRANDMEMBER key
Example
redis:6379> SADD redisKey 1 2 3 4 5 6 7 8(integer) 8redis:6379> SRANDMEMBER redisKey"5"redis:6379> SRANDMEMBER rediKey(nil)redis:6379> SRANDMEMBER redisKey"8"
No comments:
Post a Comment