EXISTS

Syntax
EXISTS key [key ...]
Available since:
1.0.0
Time complexity:
O(N) where N is the number of keys to check.
ACL categories:
@keyspace, @read, @fast,

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

redis> SET key1 "Hello"
Failed to fetch
redis> EXISTS key1
Failed to fetch
redis> EXISTS nosuchkey
Failed to fetch
redis> SET key2 "World"
Failed to fetch
redis> EXISTS key1 key2 nosuchkey
Failed to fetch
redis>

History

  • Starting with Redis version 3.0.3: Accepts multiple key arguments.
Rate this page