HPERSIST

Syntax
HPERSIST key FIELDS numfields field [field ...]
Available since:
7.4.0
Time complexity:
O(N) where N is the number of specified fields
ACL categories:
@write, @hash, @fast,

移除哈希键字段的现有过期设置,将字段从易失性(设置了过期的字段)转变为持久性(没有关联TTL(生存时间)的字段,永远不会过期)。

示例

redis> HSET mykey field1 "hello" field2 "world"
(integer 2)
redis> HEXPIRE mykey 300 FIELDS 2 field1 field2
1) (integer) 1
2) (integer) 1
redis> HTTL mykey FIELDS 2 field1 field2
1) (integer) 283
2) (integer) 283
redis> HPERSIST mykey FIELDS 1 field2
1) (integer) 1
redis> HTTL mykey FIELDS 2 field1 field2
1) (integer) 268
2) (integer) -1

RESP2/RESP3 回复

  • Array reply. 对于每个字段:
    • Integer reply: -2 如果提供的哈希键中不存在该字段,或者提供的键不存在。
    • Integer reply: -1 如果字段存在但没有设置相关的过期时间。
    • Integer reply: 1 过期时间已被移除。

RATE THIS PAGE
Back to top ↑