0
0
Redisquery~20 mins

KEYS pattern matching (avoid in production) in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis KEYS Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
What does the KEYS command return?
Given these keys in Redis: user:1, user:2, user:admin, session:1, session:2, what is the output of KEYS user:*?
Redis
KEYS user:*
A["user:1", "user:2"]
B["session:1", "session:2"]
C["user:1", "user:2", "user:admin"]
D[]
Attempts:
2 left
💡 Hint
The * wildcard matches any characters after 'user:'.
🧠 Conceptual
intermediate
1:30remaining
Why should KEYS be avoided in production?
Which of the following is the main reason to avoid using the KEYS command in a production Redis environment?
AIt requires special permissions that are unsafe to grant.
BIt deletes keys permanently without confirmation.
CIt only works with string keys, not hashes or lists.
DIt blocks the server and can cause latency spikes because it scans all keys.
Attempts:
2 left
💡 Hint
Think about what happens when KEYS scans a large database.
📝 Syntax
advanced
1:30remaining
Which KEYS command pattern matches keys ending with ':id'?
You want to find all keys that end with ':id'. Which KEYS command pattern is correct?
AKEYS *id:
BKEYS *:id
CKEYS :id*
DKEYS id:*
Attempts:
2 left
💡 Hint
The * wildcard matches any characters before ':id'.
optimization
advanced
1:30remaining
How to safely find keys matching a pattern in production?
Since KEYS is unsafe in production, which Redis command is recommended to find keys matching a pattern without blocking the server?
ASCAN with MATCH option
BDEL with pattern
CGET with pattern
DEXPIRE with pattern
Attempts:
2 left
💡 Hint
This command iterates keys incrementally without blocking.
🔧 Debug
expert
1:30remaining
What error occurs with invalid KEYS pattern?
What happens if you run KEYS user[ in Redis?
Redis
KEYS user[
ASyntax error due to incomplete pattern
BReturns an empty list because no keys match
CReturns all keys starting with 'user['
DRuntime error: invalid argument
Attempts:
2 left
💡 Hint
Check if the pattern syntax is correct.