0
0
Redisquery~10 mins

Key expiry for memory management 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 key with an expiry time of 60 seconds.

Redis
SET mykey "value" EX [1]
Drag options to blanks, or click blank then click option'
A0
B30
C60
D120
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as expiry disables expiry, so the key never expires.
Confusing milliseconds with seconds.
2fill in blank
medium

Complete the code to set a key to expire in 5 minutes using the PX option (milliseconds).

Redis
SET session_token "abc123" PX [1]
Drag options to blanks, or click blank then click option'
A300000
B3000
C5000
D60000
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3000 instead of 300000, confusing seconds and milliseconds.
Using PX with seconds value instead of milliseconds.
3fill in blank
hard

Fix the error in the command to set a key to expire in 10 seconds.

Redis
SET user_id "12345" EX [1]
Drag options to blanks, or click blank then click option'
A-10
B10
C0
D10000
Attempts:
3 left
💡 Hint
Common Mistakes
Using 10000 which is milliseconds, not seconds.
Using negative or zero values which are invalid.
4fill in blank
hard

Fill both blanks to set a key with expiry and then check its remaining TTL.

Redis
SET cache_key "data" EX [1]
TTL [2]
Drag options to blanks, or click blank then click option'
A120
Bcache_key
Cmykey
D60
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different key name in TTL than the one set.
Using wrong expiry time units.
5fill in blank
hard

Fill all three blanks to set a key with expiry, update its expiry, and check the new TTL.

Redis
SET temp_key "value" EX [1]
EXPIRE [2] [3]
TTL temp_key
Drag options to blanks, or click blank then click option'
Atemp_key
B300
C600
Dcache_key
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong key name in EXPIRE command.
Confusing expiry times or units.