EXISTS
EXISTS key [key ...]
- Group
- Keys
- Complexity
- O(N) for N keys
- Arity
- -2 (at least 2 words, counting the command name)
- Flags
- read-only, fast
- Keys
- first 1, last final argument, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
EXISTS tells you whether keys exist. With several keys it returns how many
of them exist, and a key named twice is counted twice. Checking a key does not
count as an access to it, so it does not change the key’s idle time or access
frequency.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Always | Integer: the number of named keys that exist | Integer |
Examples
Section titled “Examples”127.0.0.1:6379> SET user:1 "ada"OK127.0.0.1:6379> EXISTS user:1(integer) 1127.0.0.1:6379> EXISTS user:1 user:1 user:2(integer) 2Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.