HPTTL(3valkey)
π 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:
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),hpersist(3valkey),hpexpire(3valkey),hpexpireat(3valkey),hpexpiretime(3valkey),hrandfield(3valkey),hscan(3valkey),hset(3valkey),hsetex(3valkey),hsetnx(3valkey),hstrlen(3valkey),httl(3valkey),hvals(3valkey)
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
- 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