0
0
Redisquery~5 mins

Temporary data with TTL in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does TTL stand for in Redis?
TTL stands for Time To Live. It is the duration a key will exist before Redis automatically deletes it.
Click to reveal answer
beginner
How do you set a key with a TTL in Redis?
Use the SET command with the EX option, like SET key value EX 10 to set a key that expires in 10 seconds.
Click to reveal answer
beginner
What happens when a Redis key's TTL expires?
Redis automatically deletes the key, so it no longer exists in the database.
Click to reveal answer
beginner
How can you check the remaining TTL of a key in Redis?
Use the TTL key command. It returns the remaining time in seconds before the key expires.
Click to reveal answer
intermediate
Can you update the TTL of an existing key in Redis?
Yes, use the EXPIRE key seconds command to set or update the TTL of an existing key.
Click to reveal answer
Which Redis command sets a key with a TTL of 30 seconds?
AGET mykey EX 30
BSET mykey myvalue EX 30
CTTL mykey 30
DEXPIRE mykey 30
What does the Redis command TTL mykey return if the key does not have a TTL?
A-1
B0
Cnull
D-2
If a key's TTL expires, what happens to the key?
AIt is deleted automatically
BIt remains but becomes read-only
CIts value is set to null
DIt is moved to a backup database
Which command updates the TTL of an existing key to 60 seconds?
ASET key value EX 60
BTTL key 60
CEXPIRE key 60
DGET key EX 60
How can you create a key that never expires in Redis?
AUse TTL command with -1
BUse EXPIRE with 0 seconds
CUse SET with EX 0
DSet the key without any TTL
Explain how Redis uses TTL to manage temporary data.
Think about how Redis automatically removes data after some time.
You got /4 concepts.
    Describe how to set, check, and update TTL for a Redis key.
    Focus on the commands that control expiration.
    You got /3 concepts.