Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set a user's name in Redis.
Redis
redis.call('SET', 'user:[1]:name', 'Alice')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic words like 'user' or 'name' without an ID causes key collisions.
✗ Incorrect
The key should include the user ID to uniquely identify the user's name.
2fill in blank
mediumComplete the code to retrieve the user's email from Redis.
Redis
local email = redis.call('GET', 'user:[1]:email')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'email' or 'user' as the ID part of the key instead of the actual user ID.
✗ Incorrect
The key must include the user ID to get the correct email.
3fill in blank
hardFix the error in the code to increment the user's login count.
Redis
redis.call('[1]', 'user:789:login_count')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET replaces the value instead of incrementing it.
Using GET only reads the value without changing it.
✗ Incorrect
INCR increases the integer value stored at the key by one, perfect for counting logins.
4fill in blank
hardFill both blanks to store a user's profile with denormalized data.
Redis
redis.call('[1]', 'user:[2]', 'name', 'Bob', 'email', 'bob@example.com')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET only stores a single string, not multiple fields.
Using a generic key like 'user' without an ID causes data overwrite.
✗ Incorrect
HMSET sets multiple fields in a hash, and the key includes the user ID 101.
5fill in blank
hardFill all three blanks to create a denormalized Redis key for fast access.
Redis
redis.call('[1]', 'order:[2]:[3]', 'status', 'shipped')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET stores only a string, not multiple fields.
Missing user ID in the key reduces denormalization benefits.
✗ Incorrect
HMSET stores multiple fields, the order ID is 789, and user123 identifies the user for denormalization.