Redis supplies the SISMEMBER command to test if a particular item is already a member of a set. Using the SISMEMBER command I can test and see if apple is already a member of my fruit set.
If I construct my fruit set from the previous example, I can check and see if it contains apple using the following test:
SISMEMBER fruit apple
SISMEMBER will return a 1 since the item is already there.
If I tried to see if dog is a member of my fruit set:
SISMEMBER fruit dog
Redis will return a 0 since dog isn't in the fruit set.
If a user attempts to use the SISMEMBER command with a key that doesn't exist, Redis will return a 0 indicating no membership, but if you use SISMEMBER with a key that already holds a non-set datatype, Redis will return an error.