ExistsCommand: Contents
  EXISTS _key_
    Return value
    See also

ExistsCommand

EXISTS _key_

Time complexity: O(1)
Test if the specified key exists. The command returns"0" if the key exists, otherwise "1" is returned.Note that even keys set with an empty string as value willreturn "1".

Return value

Integer reply, specifically:

1 if the key exists.
0 if the key does not exist.

See also

  • SETNX is a SET if not EXISTS atomic operation.
  • SISMEMBER test if an element is a member of a Set.