w3resource

Redis PERSIST

PERSIST key

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).

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"

Previous: OBJECT
Next: PEXPIRE



Follow us on Facebook and Twitter for latest update.