HPERSIST(3valkey)
π HPERSIST β the valkey hash-field glow-up page π
okay so bestie, welcome to hpersist(3valkey) from the Valkey Command Manual β¨ this is the one where we take a hash field that's been living on a countdown timer and justβ¦ release it into the wild forever. no TTL, no drama, no expiration date. she's free. π¦
β¨ NAME β¨
hpersist β Remove the existing expiration on a hash key's field(s).
πΈ SYNOPSIS πΈ
HPERSIST key FIELDS numfields field [field...]
π DESCRIPTION π
So what HPERSIST does is it removes the existing expiration on a hash key's field(s). And the way that works is it flips those fields from volatile β meaning a field with an expiration set, living on borrowed time, clock ticking, stress levels high π β over to persistent, which means a field that will never expire because there's no TTL (time to live) associated with it at all. she's immortal now. periodt. π
π REPLY π
valkey-protocol(7) Array reply: it hands you back a list of integer codes telling you how it went for each field, in the exact same order you asked for them. no reshuffling, no surprises, we respect the queue bestie π«Ά
-2β Field does not exist in the provided hash key, or the hash key does not exist. π she's not here.-1β Field exists in the provided hash key, but has no expiration associated with it. already free, nothing to do π1β The expiration time was removed from the hash key field. ate. π₯
β COMPLEXITY β
O(N) where N is the number of specified fields. so like, the more fields you throw at it, the more work it does. linear babe, that's the vibe. β¨
π ACL CATEGORIES π
@fast @hash @write
π HISTORY π
- Available since:
9.0.0β she's new here but she's already iconic π
π§ EXAMPLES π§
watch and learn, this is the whole arc in one sitting:
127.0.0.1:6379> HSET myhash f1 v1 f2 v2 f3 v3
(integer) 3
27.0.0.1:6379> HEXPIRE myhash 1000 FIELDS 2 f2 f3
1) (integer) 1
2) (integer) 1
127.0.0.1:6379> HTTL myhash FIELDS 3 f1 f2 f3
1) (integer) -1
2) (integer) 998
3) (integer) 998
127.0.0.1:6379> HPERSIST myhash FIELDS 3 f1 f2 f3
1) (integer) -1
2) (integer) 1
3) (integer) 1
127.0.0.1:6379> HTTL myhash FIELDS 3 f1 f2 f3
1) (integer) -1
2) (integer) -1
3) (integer) -1
okay so let's break the vibe check down: f1 never had a TTL so it's just sitting there like -1, not me, not my problem π. then f2 and f3 had 998 seconds left on the clock, and HPERSIST said no more countdown for you and gave both of them a 1. then the HTTL check at the end shows all three at -1 β nobody's expiring, everybody's permanent. main character energy for the whole hash. π
β¨
π¦ SEE ALSO π¦
hdel(3valkey), hexists(3valkey), hexpire(3valkey), hexpireat(3valkey), hexpiretime(3valkey), hget(3valkey), hgetall(3valkey), hgetex(3valkey), hincrby(3valkey), hincrbyfloat(3valkey), hkeys(3valkey), hlen(3valkey), hmget(3valkey), hmset(3valkey), hpexpire(3valkey), hpexpireat(3valkey), hpexpiretime(3valkey), hpttl(3valkey), hrandfield(3valkey), hscan(3valkey), hset(3valkey), hsetex(3valkey), hsetnx(3valkey), hstrlen(3valkey), httl(3valkey), hvals(3valkey) β go read the whole family, they're all slay π«Ά
and that's the page bestie!! this edition is from version 9.0.0, dated 2025-10-21, and it lives in the HPERSIST(3valkey) manual. ily, go make your hash fields immortal πβ¨ππ¦
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms