EXISTS

Syntax

  1. EXISTS key [key ...]

Time complexity: O(N) where N is the number of keys to check.

Returns if key exists.

The user should be aware that if the same existing key is mentioned in the arguments multiple times, it will be counted multiple times. So if somekey exists, EXISTS somekey somekey will return 2.

Return

Integer reply, specifically the number of keys that exist from those specified as arguments.

Examples

  1. dragonfly> SET key1 "Hello"
  2. "OK"
  3. dragonfly> EXISTS key1
  4. (integer) 1
  5. dragonfly> EXISTS nosuchkey
  6. (integer) 0
  7. dragonfly> SET key2 "World"
  8. "OK"
  9. dragonfly> EXISTS key1 key2 nosuchkey
  10. (integer) 2