Recall & Review
beginner
What is key expiry in Redis?
Key expiry is a feature in Redis that allows you to set a time limit on a key. After this time, the key is automatically deleted to free up memory.
Click to reveal answer
beginner
How do you set a key to expire in Redis?
You use the EXPIRE command followed by the key name and the time in seconds. For example,
EXPIRE mykey 60 sets the key to expire in 60 seconds.Click to reveal answer
beginner
What happens when a key expires in Redis?
When a key expires, Redis automatically removes it from the database, freeing up the memory it used.
Click to reveal answer
beginner
Can you check the remaining time to live (TTL) of a key in Redis?
Yes, you use the TTL command with the key name. It returns the remaining time in seconds before the key expires.
Click to reveal answer
beginner
Why is key expiry important for memory management in Redis?
Key expiry helps automatically clean up unused or temporary data, preventing memory from filling up and keeping Redis fast and efficient.
Click to reveal answer
Which Redis command sets a key to expire after a certain time?
✗ Incorrect
The EXPIRE command sets a time limit on a key after which it is deleted.
What does the TTL command return in Redis?
✗ Incorrect
TTL returns how many seconds remain before the key expires.
What happens when a key expires in Redis?
✗ Incorrect
Expired keys are automatically removed to free memory.
Why is setting key expiry useful in Redis?
✗ Incorrect
Key expiry helps manage memory by removing data that is no longer needed.
Which of these is NOT a valid way to set expiry on a key in Redis?
✗ Incorrect
TTL is used to check expiry time, not to set it.
Explain how key expiry helps with memory management in Redis.
Think about what happens to keys after their expiry time.
You got /4 concepts.
Describe how to set and check expiry time for a key in Redis.
Commands EXPIRE and TTL are key here.
You got /4 concepts.