EXISTS key [key ...]
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.
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
EXISTS somekey somekey will return 2.
Integer reply, specifically:
1if the key exists.
0if the key does not exist.
Since Redis 3.0.3 the command accepts a variable number of keys and the return value is generalized:
"OK"redis> EXISTS key1
(integer) 1redis> EXISTS nosuchkey
(integer) 0redis> SET key2 "World"
"OK"redis> EXISTS key1 key2 nosuchkey
© 2009–2020 Salvatore Sanfilippo
Licensed under the Creative Commons Attribution-ShareAlike License 4.0.