0
0
Redisquery~10 mins

EXPIRE and TTL for time-to-live 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 to expire after 60 seconds.

Redis
EXPIRE mykey [1]
Drag options to blanks, or click blank then click option'
A6
B600
C60
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 will delete the key immediately.
Using 600 sets expiration to 10 minutes, not 1 minute.
2fill in blank
medium

Complete the code to check the remaining time to live of a key.

Redis
TTL [1]
Drag options to blanks, or click blank then click option'
Amykey
Bsession
Cexpire
Dtimeout
Attempts:
3 left
💡 Hint
Common Mistakes
Using a command name instead of a key name.
Using a key that does not exist returns -2.
3fill in blank
hard

Fix the error in the command to set expiration to 120 seconds.

Redis
EXPIRE mykey [1]
Drag options to blanks, or click blank then click option'
A1m
B120
Ctwo_minutes
D-120
Attempts:
3 left
💡 Hint
Common Mistakes
Using text instead of a number.
Using negative numbers.
4fill in blank
hard

Fill both blanks to set a key to expire and then check its TTL.

Redis
EXPIRE [1] 30
TTL [2]
Drag options to blanks, or click blank then click option'
Acache
Bsession
Attempts:
3 left
💡 Hint
Common Mistakes
Using different key names in EXPIRE and TTL commands.
Using a key that does not exist.
5fill in blank
hard

Fill all three blanks to set a key expiration, check TTL, and remove expiration.

Redis
EXPIRE [1] 45
TTL [2]
PERSIST [3]
Drag options to blanks, or click blank then click option'
Atempkey
Attempts:
3 left
💡 Hint
Common Mistakes
Using different key names in commands.
Confusing PERSIST with EXPIRE.