Redis PERSIST Command
The Redis PERSIST command is used to remove the expiration time of 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 Versions
>= 2.2.0
Return Value
Returns 1 when the expiration time is removed successfully. If the key does not exist or the key has no expiration time set, returns 0.
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
Other Extensions
Redis Key