Challenge - 5 Problems
Redis KEYS Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1: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:*
Attempts:
2 left
💡 Hint
The * wildcard matches any characters after 'user:'.
✗ Incorrect
The KEYS command with pattern 'user:*' returns all keys starting with 'user:' including 'user:admin'.
🧠 Conceptual
intermediate1: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?
Attempts:
2 left
💡 Hint
Think about what happens when KEYS scans a large database.
✗ Incorrect
KEYS scans the entire keyspace which blocks Redis and can cause performance issues in production.
📝 Syntax
advanced1: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?
Attempts:
2 left
💡 Hint
The * wildcard matches any characters before ':id'.
✗ Incorrect
The pattern '*:id' matches any key ending with ':id'.
❓ optimization
advanced1: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?
Attempts:
2 left
💡 Hint
This command iterates keys incrementally without blocking.
✗ Incorrect
SCAN iterates keys in small batches and supports pattern matching with MATCH, avoiding blocking.
🔧 Debug
expert1:30remaining
What error occurs with invalid KEYS pattern?
What happens if you run
KEYS user[ in Redis?Redis
KEYS user[
Attempts:
2 left
💡 Hint
Check if the pattern syntax is correct.
✗ Incorrect
The pattern 'user[' is incomplete and causes a syntax error in Redis.