hpttl.3valkey - Man Page
Returns the remaining time to live in milliseconds of a hash key’s field(s) that have an associated expiration.
Synopsis
HPTTL key FIELDS numfields field [field...]
Description
Like valkey-httl(7) HTTL this command returns the remaining time to live of hash field(s) that has an associated expiration time, with the sole difference that HTTL returns the amount of remaining time in seconds while HPTTL returns it in milliseconds.
See also the valkey-httl(7) HTTL command that returns the same information with seconds resolution.
Reply
valkey-protocol(7) 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.
- -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(1) for each field assigned with TTL, so O(N) for N items when the command is called with multiple fields.
Acl Categories
@fast @hash @read
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> HPEXPIRE myhash 10000 FIELDS 2 f2 f3 1) (integer) 1 2) (integer) 1 127.0.0.1:6379> HPTTL myhash FIELDS 3 f1 f2 f3 1) (integer) -1 2) (integer) 9597 3) (integer) 9597
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), hpexpiretime(3valkey), hrandfield(3valkey), hscan(3valkey), hset(3valkey), hsetex(3valkey), hsetnx(3valkey), hstrlen(3valkey), httl(3valkey), hvals(3valkey)