HEXPIRE · Valkey

HEXPIRE

Sets expiry time on hash fields.

Usage

HEXPIRE key seconds [NX | XX | GT | LT] FIELDS numfields field [field…]

Description

The HEXPIRE command allows manipulating the expiration time for existing hash fields. When set, the expiration time of a hash field will determine when the field will be automatically deleted. Note, that providing a millisecond time of ‘0’ will cause immediate expiration and deletion of the field(s).

Options

The HEXPIRE command supports a set of options that modify its behavior:

Reply

Array reply: a list of integer codes indicating the result of setting expiry on each specified field, in the same order as the fields are requested.

Complexity

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

ACL Categories

@fast @hash @write

Examples

127.0.0.1:6379> HSET myhash f1 v1 f2 v2 f3 v3
(integer) 3
27.0.0.1:6379> HEXPIRE myhash 10 FIELDS 2 f2 f3
1) (integer) 1
2) (integer) 1
127.0.0.1:6379> HTTL myhash FIELDS 3 f1 f2 f3
1) (integer) -1
2) (integer) 8
3) (integer) 8

History

See also

HDEL, HEXISTS, HEXPIREAT, HEXPIRETIME, HGET, HGETALL, HGETEX, HINCRBY, HINCRBYFLOAT, HKEYS, HLEN, HMGET, HMSET, HPERSIST, HPEXPIRE, HPEXPIREAT, HPEXPIRETIME, HPTTL, HRANDFIELD, HSCAN, HSET, HSETEX, HSETNX, HSTRLEN, HTTL, HVALS.