Redis PERSIST – How to remove expiration time of key in redis

2 months ago Lalit Bhagtani 0

In this tutorial, we will learn about how to remove expiration time ( timeout ) of a key stored in redis datastore, by using a COMMAND – PERSIST in redis-cli. When we set an expiration time on a key using EXPIRE/PEXPIRE or EXPIREAT/PEXPIREAT, its state becomes Volatile ( a key with an expiration time set ). PERSIST command change its state to Persist state by removing expiration time associated with it. The syntax of redis PERSIST command is as follows :-

Syntax :-

redis host:post> PERSIST <key name>

Output :-

- 1 if the timeout of key was removed.
- 0 if key does not exist or does not have a timeout.

Example :-


References :-

  1. PERSIST Command Docs

That’s all for how to remove expiration time of a key in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.