HGETEX(3valkey)
π HGETEX π
okay bestie, welcome to the Valkey Command Manual β¨ this one's from the valkey section (3), and it's genuinely one of the cutest hash commands out there, no cap π
πΈ NAME πΈ
hgetex β grab the value of one or more fields from a given hash key, and optionally set their expiration time or their time-to-live (TTL). like, read and schedule the goodbye in one go π
β¨ SYNOPSIS β¨
HGETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT
unix-time-milliseconds | PERSIST] FIELDS numfields field [field...]
π¦ DESCRIPTION π¦
So the HGETEX command returns the value of one or more fields of a given hash key, and it optionally messes with their expiration time. iconic
It gives you back an array that's the same size as the number of fields you asked for β literally one slot per field, bestie, no surprises π
And here's the chill part: if you don't pass any of the optional flags at all, this command behaves exactly like a regular valkey-hmget(7) HMGET command. same energy, same output. periodt π
π OPTIONS π
HGETEX supports a lil set of options that change how it behaves:
EX secondsβ set the expiration time you want, measured in seconds β°PX millisecondsβ set the expiration time you want, measured in milliseconds π«ΆEXAT unix-time-secondsβ set the exact Unix time at which the fields will expire, in seconds βPXAT unix-time-millisecondsβ set the exact Unix time at which the fields will expire, in milliseconds βPERSISTβ remove the expiration time that's attached to the fields π
Notes for the following, bestie, read these fr fr:
- The
EX,PX,EXAT,PXAT, andPERSISToptions are mutually exclusive. pick one, okay? not a combo meal π - Providing a
0' expiration TTL via theEXorPX` optional arguments will cause the specified fields to expire immediately and be removed from the hash. like, gone gone π - Providing a past expiration time via the
EXATorPXAToptional arguments will also cause the specified fields to expire immediately and be removed from the hash. same fate, different route π
π REPLY π
valkey-protocol(7) Array reply: a list of values associated with the given fields, in the same order as they were requested. order matters, bestie, it always does β¨
π§ COMPLEXITY π§
O(N) where N is the number of specified fields. so like, the more fields you ask for, the more work it does β math is math π
π ACL CATEGORIES π
@fast @hash @write
π HISTORY π
- Available since: 9.0.0 β a fresh baby, a new gen icon π
π EXAMPLES π
127.0.0.1:6379> HSET myhash f1 v1 f2 v2 f3 v3
(integer) 3
27.0.0.1:6379> HGETEX myhash EX 10 FIELDS 2 f2 f3
1) "v2"
2) "v3"
127.0.0.1:6379> HTTL myhash FIELDS 3 f1 f2 f3
1) (integer) -1
2) (integer) 8
3) (integer) 8
127.0.0.1:6379> HGETEX myhash EX 0 FIELDS 3 f1 f2 f3
1) "v1"
2) "v2"
3) "v3"
127.0.0.1:6379> HGETEX myhash FIELDS 3 f1 f2 f3
1) (nil)
2) (nil)
3) (nil)
like, watch f1 get a -1 (no expiry, living its best life), then everybody gets an EX 0 and suddenly the whole hash is empty. main character exit π«Ά
π₯ SEE ALSO π₯
hdel(3valkey), hexists(3valkey), hexpire(3valkey), hexpireat(3valkey), hexpiretime(3valkey), hget(3valkey), hgetall(3valkey), hincrby(3valkey), hincrbyfloat(3valkey), hkeys(3valkey), hlen(3valkey), hmget(3valkey), hmset(3valkey), hpersist(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)
and that's the whole page, bestie π this was 9.0.0, dated 2025-10-21, straight from the HGETEX(3valkey) page β go forth and expire things responsibly, ily πβ¨π¦
π¦ 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