Get the value of one or more fields of a given hash key, and optionally set their expiration time or time-to-live (TTL).
HGETEX key
[EX seconds |
PX milliseconds |
EXAT unix-time-seconds |
PXAT unix-time-milliseconds |
PERSIST]
FIELDS numfields field
[field…]
The HGETEX command returns the value of one or more
fields of a given hash key, and optionally manipulates their expiration
time. The command will return an array in the size of the number of
requested fields. Without providing any optional flags, this command
behaves exactly like a normal HMGET command.
The HGETEX command supports a set of options that modify
its behavior:
unix-time-seconds — Set the specified Unix time at
which the fields will expire, in seconds.unix-time-milliseconds — Set the specified Unix
time at which the fields will expire, in milliseconds.Note for the following:
EX or PX
optional arguments will cause the specified fields to expire immediately
and be removed from the hash.EXAT or
PXAT optional arguments will cause the specified fields to
expire immediately and be removed from the hash.Array reply: a list of values associated with the given fields, in the same order as they are requested.
O(N) where N is the number of specified fields.
@fast @hash @write
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)
HDEL, HEXISTS, HEXPIRE, HEXPIREAT, HEXPIRETIME, HGET, HGETALL, HINCRBY, HINCRBYFLOAT, HKEYS, HLEN, HMGET, HMSET, HPERSIST, HPEXPIRE, HPEXPIREAT, HPEXPIRETIME, HPTTL, HRANDFIELD, HSCAN, HSET, HSETEX, HSETNX, HSTRLEN, HTTL, HVALS.