SMEMBERS command in redis

SMEMBERS key

Return all the members (elements) of the set value stored at the key.

TIME COMPLEXITY: O(N)

RETURN VALUE: Multi bulk reply

Syntax:

SMEMBERS key

Example 1: When the key is present.

redis:6379> SADD key1 a b c d
(integer) 4
redis:6379> SMEMBERS key1
1) "c"
2) "a"
3) "d"
4) "b"

Output

1) "c"

2) "a"

3) "d"

4) "b"


Example 2: When the key is not present.

redis:6379> SMEMBERS redisKey
(empty array)

Output

empty array


No comments:

Post a Comment