HTTL

HTTL key FIELDS numfields field [field ...]
Railroad diagram for HTTL
httl(
    key: KeyT,  // The hash key.
    *fields: str
) → ResponseT  // Returns a list which contains for each field in the request: - `-2` if the field does not exist, or if the key does not exist. - `-1` if the field exists but has no associated expire time. - A positive integer representing the TTL in seconds if the field has an associated expiration time.
Available since:
Redis Open Source 7.4.0
Time complexity:
O(N) where N is the number of specified fields
ACL categories:
@read, @hash, @fast,
Compatibility:
Redis Software and Redis Cloud compatibility

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.

Required arguments

key

The name of the key that holds the hash.

FIELDS numfields field [field ...]

The hash fields to retrieve the remaining time to live for. numfields is the number of fields, followed by that many field names.

Examples

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

Redis Software and Redis Cloud compatibility

Redis
Software
Redis
Cloud
Notes
✅ Standard
✅ Active-Active
✅ Standard
✅ Active-Active

Return information

RATE THIS PAGE
Back to top ↑
Morty Proxy This is a proxified and sanitized view of the page, visit original site.