HTTL
Syntax
HTTL key FIELDS numfields field [field ...]
- Available since:
- 7.4.0
- Time complexity:
- O(N) where N is the number of specified fields
- ACL categories:
-
@read
,@hash
,@fast
,
Returns the remaining TTL (time to live) of a hash key's field(s) that have a set expiration. This introspection capability allows you to check how many seconds a given hash field will continue to be part of the hash key.
See also the HPTTL
command that returns the same information with millisecond resolution.
Example
redis> HTTL no-key FIELDS 3 field1 field2 field3
(nil)
redis> HSET mykey field1 "hello" field2 "world"
(integer) 2
redis> HEXPIRE mykey 300 FIELDS 2 field1 field3
1) (integer) 1
2) (integer) -2
redis> HTTL mykey FIELDS 3 field1 field2 field3
1) (integer) 283
2) (integer) -1
3) (integer) -2
RESP2/RESP3 Reply
- Array reply. For each field:
- Integer reply:
-2
if no such field exists in the provided hash key, or the provided key does not exist. - Integer reply:
-1
if the field exists but has no associated expiration set. - Integer reply: the TTL in seconds.
- Integer reply: