SISMEMBER command in redis

SISMEMBER key member

Return 1 if the member is a member of the set stored at key, otherwise, 0 is returned.

TIME COMPLEXITY: O(1)

RETURN VALUE: Integer reply, specifically:

1 if the element is a member of the set

0 if the element is not a member of the set OR if the key does not exist.

Syntax:

SISMEMBER key member

Example 1: When the value is present in the key.

redis:6379> SISMEMBER key1 a
(integer) 1

Output

1


Example 2: When the value is not present in the key.

redis:6379> SISMEMBER key1 100
(integer) 0

Output

0


No comments:

Post a Comment