Redis SISMEMBER – How to check existence of an element in the set

2 months ago Lalit Bhagtani 0

In this tutorial, we will learn about how to check, if a specified element is a member of the set or not. For this we will use a COMMAND – SISMEMBER in redis-cli. The syntax of redis SISMEMBER command is as follows :-

Syntax :-

redis host:post> SISMEMBER <key name>

Output :- 

 (integer) 1 if element is member of the set.
 (integer) 0 if element is not member of the set, or if key does not exist.
 error, if key exist and value stored at the key is not a set.

Example :-

Redis SISMEMBER

References :-

  1. SISMEMBER Command Docs

That’s all for how to check, if a specified element is a member of the set or not in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.