0
0
Redisquery~20 mins

EXISTS to check key existence in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis EXISTS Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:00remaining
Check if a single key exists
Given the Redis database contains keys: user:1, user:2, and session:1, what is the output of the command EXISTS user:1?
Redis
EXISTS user:1
A1
B0
CError: key not found
Dnull
Attempts:
2 left
💡 Hint
EXISTS returns 1 if the key exists, otherwise 0.
query_result
intermediate
1:30remaining
Check multiple keys existence count
What does the command EXISTS user:1 user:3 session:1 return if only user:1 and session:1 exist in the Redis database?
Redis
EXISTS user:1 user:3 session:1
A3
B1
C2
D0
Attempts:
2 left
💡 Hint
EXISTS returns the number of keys that exist among the given keys.
📝 Syntax
advanced
1:30remaining
Identify the syntax error in EXISTS command
Which option shows an invalid syntax for the EXISTS command in Redis?
AEXISTS user:3
BEXISTS (user:1)
CEXISTS session:1
DEXISTS user:1 user:2
Attempts:
2 left
💡 Hint
EXISTS command does not use parentheses around keys.
optimization
advanced
2:00remaining
Optimizing key existence checks
You want to check if any of the keys user:1, user:2, user:3 exist. Which command is the most efficient to get the count of existing keys?
AEXISTS user:1; EXISTS user:2; EXISTS user:3
BKEYS user:*
CGET user:1 user:2 user:3
DEXISTS user:1 user:2 user:3
Attempts:
2 left
💡 Hint
EXISTS can take multiple keys at once and returns the count of existing keys.
🧠 Conceptual
expert
2:00remaining
Behavior of EXISTS with expired keys
If a key named session:temp has expired and been deleted by Redis, what will EXISTS session:temp return?
Redis
EXISTS session:temp
A0
B1
CError: key expired
Dnull
Attempts:
2 left
💡 Hint
Expired keys are automatically removed and do not exist anymore.