0
0
Redisquery~20 mins

PERSIST to remove expiry in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Persist Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
What is the output of the PERSIST command?
Given a Redis key session_token with an expiry set, what will be the output of the command PERSIST session_token if the key exists and has an expiry?
Redis
SET session_token abc123
EXPIRE session_token 300
PERSIST session_token
A0
BError: wrong number of arguments
Cnil
D1
Attempts:
2 left
💡 Hint
PERSIST removes the expiry from a key if it exists and has a timeout.
query_result
intermediate
1:30remaining
What happens when PERSIST is called on a key without expiry?
If a Redis key user:100 exists but has no expiry set, what will PERSIST user:100 return?
Redis
SET user:100 "John Doe"
PERSIST user:100
AError: key does not exist
B1
C0
Dnil
Attempts:
2 left
💡 Hint
PERSIST only removes expiry if one exists.
📝 Syntax
advanced
1:30remaining
Which PERSIST command syntax is correct?
Identify the correct syntax to remove the expiry from a Redis key named cache_data.
APERSIST cache_data
BPERSIST(cache_data)
CPERSIST 'cache_data'
DPERSIST cache_data EXPIRE
Attempts:
2 left
💡 Hint
Redis commands do not use parentheses or extra keywords for PERSIST.
🧠 Conceptual
advanced
2:00remaining
Why use PERSIST instead of deleting and recreating a key?
Which of the following is the best reason to use PERSIST to remove expiry from a key instead of deleting and recreating it?
ADeleting and recreating is faster and safer.
BPERSIST preserves the key's value and metadata without interruption.
CPERSIST automatically backs up the key to disk.
DDeleting a key does not remove its expiry.
Attempts:
2 left
💡 Hint
Think about what happens to the key's data and connections.
🔧 Debug
expert
2:00remaining
Why does PERSIST return 0 unexpectedly?
You run PERSIST mykey but it returns 0 even though you expect the key to have an expiry. Which is the most likely cause?
AThe key <code>mykey</code> exists but has no expiry set.
BThe Redis server is down.
CThe key <code>mykey</code> does not exist in Redis.
DPERSIST command is deprecated and no longer works.
Attempts:
2 left
💡 Hint
PERSIST returns 0 if no expiry was removed.