Easy Tutorial
❮ Redis Sorted Sets Transactions Watch ❯

Redis PERSIST Command

Redis Keys

The Redis PERSIST command is used to remove the expiration from a given key, making the key persistent.

Syntax

The basic syntax of the redis PERSIST command is as follows:

redis 127.0.0.1:6379> PERSIST KEY_NAME

Available Versions

= 2.2.0

Return Value

Returns 1 when the expiration is successfully removed. Returns 0 if the key does not exist or if the key does not have an expiration set.

Example

redis> SET mykey "Hello"
OK

redis> EXPIRE mykey 10  # Set the expiration time for the key
(integer) 1

redis> TTL mykey
(integer) 10

redis> PERSIST mykey    # Remove the expiration time from the key
(integer) 1

redis> TTL mykey
(integer) -1

Redis Keys

❮ Redis Sorted Sets Transactions Watch ❯