Redis PERSIST
Redis PERSIST Command
Redis PERSIST command is used to remove the existing timeout on key, turning the key from volatile (a key with an expire set) to persistent (a key that will never expire as no timeout is associated).
Here are some common uses and scenarios for the "PERSIST" command:
- Convert Temporary Data: Turn keys with expiration into permanent storage.
- Cache Management: Adjust TTL dynamically or make certain cache entries permanent.
- Session Handling: Ensure critical session data persists beyond temporary TTL.
- Data Stability: Prevent automatic deletion of important data due to TTL expiry.
Syntax:
PERSIST KEY_NAME
Available since
2.2.0.
Return Value
-
Integer reply, specifically :
- 1, if the timeout is removed from the key.
- 0, if the key does not exist or does not have an associated timeout.
Return Value Type
Integer
Example: Redis PERSIST
First, create a key in redis and set some value in it.
127.0.0.1:6379[1]> SET key "JavaScript" OK 127.0.0.1:6379[1]> EXPIRE key 20 (integer) 1 127.0.0.1:6379[1]> TTL key (integer) 16 127.0.0.1:6379[1]> PERSIST key (integer) 1 127.0.0.1:6379[1]> TTL key (integer) -1 127.0.0.1:6379[1]> Get key "JavaScript"
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/redis/redis-persist-key.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics