Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis PERSIST Command

Redis PERSIST Command

Redis Key

The Redis PERSIST command is used to remove the expiration from a given key, so that the key never expires.

Syntax

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



redis 127.0.0.1:6379> PERSIST KEY_NAME

Available Version

= 2.2.0

Return Value

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

Example



redis> SET mykey "Hello"

OK



redis> EXPIRE mykey 10  # 为 key 设置生存时间

(integer) 1



redis> TTL mykey

(integer) 10



redis> PERSIST mykey    # 移除 key 的生存时间

(integer) 1



redis> TTL mykey

(integer) -1

Redis Key