HPERSIST(3valkey)

πŸ“¦ version 9.0.6, in fedora 44

πŸ’– 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