HPTTL(3valkey)

πŸ“¦ version 9.0.6, in fedora 44

πŸ’– HPTTL β€” the valkey manual, but make it cute ✨

okay bestie, sit down, hydrate, because we're about to talk about HPTTL, a real one from the valkey section 3 command manual. this is the glow-up of HTTL and she's measuring in milliseconds, because sometimes seconds just isn't enough precision, and that's valid. πŸŽ€


🌸 NAME 🌸

hpttl β€” returns the remaining time to live in milliseconds of a hash key's field(s) that have an associated expiration. literally the countdown timer but make it fancy. β³πŸ’…


✨ SYNOPSIS ✨

HPTTL key FIELDS numfields field [field...]

that's it, that's the whole vibe. you bring the key, you say FIELDS, you say how many, you list them. slay. πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

so, like, it's the same energy as valkey-httl(7) HTTL β€” this command returns the remaining time to live of hash field(s) that has an associated expiration time. the sole difference (and it's giving main character) is that HTTL returns the amount of remaining time in seconds, while HPTTL returns it in milliseconds. more digits, more drama, more accuracy. no cap. πŸ”₯

also go peep the valkey-httl(7) HTTL command if you want the same info with seconds resolution. both are iconic, just different fonts. πŸ’œ


🫢 REPLY 🫢

valkey-protocol(7) Array reply: a list of values associated with the result of getting the remaining time-to-live of the specific fields, in the same order as they are requested. order is preserved, bestie, we are not shuffling your fields. πŸ‘‘

  • -2: Field does not exist in the provided hash key, or the hash key is empty. (she's not here, she left the group chat πŸ’€)
  • -1: Field exists in the provided hash key, but has no expiration associated with it. (alive and well, just no timer set πŸ™ˆ)
  • valkey-protocol(7) Integer: The expiration time associated with the hash key field, in milliseconds. (the actual countdown, in ms ⏰)

🧚 COMPLEXITY 🧚

O(N) where N is the number of specified fields.

translation: the more fields you ask about, the more work she does. it scales, she's built different. πŸ’ͺ✨


🌈 ACL CATEGORIES 🌈

@fast @hash @read

fast, hash-y, and read-only. the holy trinity of "chill, she won't break anything." πŸ“


πŸ‘‘ HISTORY πŸ‘‘

  • Available since: 9.0.0

a fresh-faced icon. she's new here and already ate. 🌟


πŸ’… EXAMPLES πŸ’…

here's the whole thing in action, verbatim, don't touch the numbers:

127.0.0.1:6379> HSET myhash f1 v1 f2 v2 f3 v3
(integer) 3
27.0.0.1:6379> HPEXPIRE myhash 10000 FIELDS 2 f2 f3
1) (integer) 1
2) (integer) 1
127.0.0.1:6379> HPTTL myhash FIELDS 3 f1 f2 f3
1) (integer) -1
2) (integer) 9597
3) (integer) 9597

see how f1 says -1? that's her saying "no expiration on me bestie." and f2 / f3 are ticking down in ms. perfect. no notes. πŸŽ€


πŸ”₯ SEE ALSO πŸ”₯

the whole friend group, alphabetically assembled:

go read them all, they're all bangers. iykyk. πŸ“šπŸ’–

and that's the tea, bestie πŸ«– β€” this page is from valkey version 9.0.0, dated 2025-10-21. go forth and measure your hash field expirations in milliseconds like the precision queen you are. mwah. πŸ’‹βœ¨πŸŒΈ

πŸ“¦ where this page comes from