English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis PERSIST Command

Redis key (key)

The Redis PERSIST command is used to remove the expiration time of the given key, making the key never expire.

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

When the expiration time is removed successfully, return 1 . If the key does not exist or the key does not have an expiration time, return 0 .

Online Examples

redis> SET mykey "Hello"
OK
redis> EXPIRE mykey 10  # Set expiration time for the key
(integer) 1
redis> TTL mykey
(integer) 10
redis> PERSIST mykey    # Remove the expiration time of the key
(integer) 1
redis> TTL mykey
(integer) -1

Redis key (key)