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?
✗ Incorrect
The
SET command with EX 30 sets the key and its TTL in one step.What does the Redis command
TTL mykey return if the key does not have a TTL?✗ Incorrect
Redis returns
-1 if the key exists but has no expiration set.If a key's TTL expires, what happens to the key?
✗ Incorrect
Redis deletes keys automatically when their TTL expires.
Which command updates the TTL of an existing key to 60 seconds?
✗ Incorrect
The
EXPIRE command sets or updates the TTL of an existing key.How can you create a key that never expires in Redis?
✗ Incorrect
Keys without TTL never expire unless deleted manually.
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.