0
0
Redisquery~20 mins

Hash slots distribution in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Hash Slots Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Hash slot calculation for a given key
Given the Redis key {user:1000}.data, what is the hash slot number assigned to this key in a Redis cluster?
AThe hash slot is randomly assigned and not related to the key content.
BThe hash slot is calculated on the entire key <code>{user:1000}.data</code> including the braces and suffix.
CThe hash slot is always zero for keys with curly braces.
DThe hash slot is calculated only on the substring inside curly braces, so the slot corresponds to the hash of <code>user:1000</code>.
Attempts:
2 left
💡 Hint
Redis cluster uses the substring inside curly braces to compute the hash slot.
🧠 Conceptual
intermediate
1:30remaining
Purpose of hash slots in Redis cluster
What is the main purpose of hash slots in a Redis cluster?
ATo encrypt data stored in Redis for security.
BTo compress keys to save memory space.
CTo distribute keys evenly across multiple nodes for load balancing.
DTo store keys in a single node only.
Attempts:
2 left
💡 Hint
Think about how Redis cluster manages data across nodes.
📝 Syntax
advanced
1:30remaining
Identify the correct command to view hash slot allocation
Which Redis CLI command correctly shows the hash slot allocation for cluster nodes?
ACLUSTER SLOTS
BCLUSTER INFO
CCLUSTER NODES
DCLUSTER KEYSLOT <key>
Attempts:
2 left
💡 Hint
The command should show slot ranges assigned to nodes.
🔧 Debug
advanced
2:00remaining
Troubleshooting key slot mismatch error
You get a MOVED error when accessing a key in Redis cluster. What is the most likely cause?
AThe client sent the key to the wrong node that does not own the key's hash slot.
BThe key does not exist in the cluster.
CThe key contains invalid characters.
DThe Redis server is down.
Attempts:
2 left
💡 Hint
MOVED errors indicate redirection to the correct node.
optimization
expert
2:30remaining
Optimizing multi-key operations with hash slots
You want to perform a multi-key operation (e.g., MGET) on keys user:1, user:2, and user:3 in a Redis cluster. How should you design the keys to ensure the operation succeeds without errors?
AUse completely different key names without curly braces.
BUse the same hash tag in curly braces for all keys, like <code>{user}:1</code>, <code>{user}:2</code>, <code>{user}:3</code>.
CUse keys with different hash tags, like <code>{user1}:1</code>, <code>{user2}:2</code>, <code>{user3}:3</code>.
DUse keys with no hash tags but ensure they are stored on the same node manually.
Attempts:
2 left
💡 Hint
Multi-key commands require keys to be in the same hash slot.