HPEXPIRETIME(3valkey)
π HPEXPIRETIME π
ok so this is hpexpiretime, straight out of the Valkey Command Manual (section 3valkey, iykyk), and bestie it is SO useful. It tells you the exact Unix timestamp in milliseconds since the Unix epoch at which a given key's field(s) are gonna expire. like a lil countdown but make it absolute. π°οΈβ¨
β¨ NAME β¨
hpexpiretime β returns the Unix timestamp in milliseconds since Unix epoch at which the given key's field(s) will expire πΈ
π SYNOPSIS π
HPEXPIRETIME key FIELDS numfields field [field...]
π¦ DESCRIPTION π¦
The HPEXPIRETIME command returns the absolute Unix timestamp (since January 1, 1970) in milliseconds at which the given hash field(s) will expire. no cap, absolute β not "in 300 seconds", it's giving "this is the literal moment, put it in your calendar". π
Also peep the valkey-hexpiretime(7) HEXPIRETIME command, which hands you the exact same info but with seconds resolution instead of milliseconds. same vibe, chiller precision. β¨
π REPLY π
valkey-protocol(7) Array reply: a list of values associated with the result of getting the absolute expiry timestamp of the specific fields, in the same order as they are requested. order matters bestie, it always does. π
-2: Field does not exist in the provided hash key, or the hash key is empty. π-1: Field exists in the provided hash key, but has no expiration associated with it. πvalkey-protocol(7)Integer: The expiration time associated with the hash key field, in milliseconds. β
π₯ COMPLEXITY π₯
O(N) where N is the number of specified fields. the more fields you ask about, the more work it does, that's just math. π§
π ACL CATEGORIES π
@fast @hash @read β she's fast, she's hashy, she's read-only, she's iconic. π
πΈ HISTORY πΈ
- Available since:
9.0.0π
π EXAMPLES π
127.0.0.1:6379> HSET myhash f1 v1 f2 v2 f3 v3
(integer) 3
27.0.0.1:6379> HPEXPIREAT myhash 1754847944000 FIELDS 2 f2 f3
1) (integer) 1
2) (integer) 1
127.0.0.1:6379> HPEXPIRETIME myhash FIELDS 4 f1 f2 f3 non-exist
1) (integer) -1
2) (integer) 1754847944000
3) (integer) 1754847944000
4) (integer) -2
look at that. f1 said "no expiration, I'm free" (-1), f2 and f3 are locked in till 1754847944000, and non-exist is just... not there (-2). main character behavior from non-exist honestly. πβ¨
π«Ά 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), hpersist(3valkey), hpexpire(3valkey), hpexpireat(3valkey), hpttl(3valkey), hrandfield(3valkey), hscan(3valkey), hset(3valkey), hsetex(3valkey), hsetnx(3valkey), hstrlen(3valkey), httl(3valkey), hvals(3valkey) β the whole friend group, go say hi. π
ok that's the whole page bestie, no skips, no cuts, every flag and number kept exactly where it was. π«Ά
version 9.0.0, dated 2025-10-21 β mwah, that's a wrap, slay the day and go check ur field expiries. π
β¨π
π¦ 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