HTTL · Valkey

HTTL

Returns the remaining time to live (in seconds) of a hash key’s field(s) that have an associated expiration.

Usage

HTTL key FIELDS numfields field [field…]

Description

The HTTL command returns the remaining time to live of hash field(s) with associated expiration time(s). This introspection capability allows a Valkey client to check how many seconds a given hash field will continue to be part of the hash object.

See also the HPTTL command that returns the same information with milliseconds resolution.

Reply

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.

Complexity

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

ACL Categories

@fast @hash @read

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 4 f1 f2 f3 non-exist
1) (integer) -1
2) (integer) 8
3) (integer) 8
4) (integer) -2

History

See also

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