EXISTS key [key …]
Time complexity: O(1)
Returns if exists.
Since Redis 3.0.3 it is possible to specify multiple keys instead of a single one. In such a case, it returns the total number of keys existing. Note that returning 1 or 0 for a single key is just a special case of the variadic usage, so the command is completely backward compatible.
, specifically:
- if the key exists.
Since Redis 3.0.3 the command accepts a variable number of keys and the return value is generalized:
- The number of keys existing among the ones specified as arguments. Keys mentioned multiple times and existing are counted multiple times.
*Examples
redis> SET key1 "Hello"
redis> EXISTS nosuchkey
redis> SET key2 "World"
redis> EXISTS key1 key2 nosuchkey
redis>