0
0
Redisquery~10 mins

Session storage pattern in Redis - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set a session key with a value in Redis.

Redis
SET session:user123 [1]
Drag options to blanks, or click blank then click option'
A"active"
BEXPIRE
CGET
DDEL
Attempts:
3 left
💡 Hint
Common Mistakes
Using commands like EXPIRE or GET instead of a value.
Forgetting to provide a value after the key.
2fill in blank
medium

Complete the code to set an expiration time of 3600 seconds on a session key.

Redis
EXPIRE session:user123 [1]
Drag options to blanks, or click blank then click option'
A60
B0
C1800
D3600
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 which means no expiration.
Using a time too short or too long by mistake.
3fill in blank
hard

Fix the error in the command to retrieve the session value.

Redis
[1] session:user123
Drag options to blanks, or click blank then click option'
ASET
BEXPIRE
CGET
DDEL
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET instead of GET to retrieve data.
Using EXPIRE or DEL which do not return the value.
4fill in blank
hard

Fill both blanks to delete a session key and then check if it still exists.

Redis
DEL [1]
EXISTS [2]
Drag options to blanks, or click blank then click option'
Asession:user456
Bsession:user123
Csession:user789
Dsession:user000
Attempts:
3 left
💡 Hint
Common Mistakes
Using different keys in DEL and EXISTS commands.
Using keys that were not set before.
5fill in blank
hard

Fill all three blanks to set a session key with a value and expiration in one command.

Redis
SET [1] [2] [3] 1800
Drag options to blanks, or click blank then click option'
Asession:user789
B"logged_in"
CEX
DNX
Attempts:
3 left
💡 Hint
Common Mistakes
Using NX which means set only if key does not exist, not expiration.
Forgetting to put quotes around the value string.