SPTTL

SPTTL key MEMBERS nummembers member [member ...]
Available since:
Redis Open Source 8.12.0
Time complexity:
O(N) where N is the number of specified members
ACL categories:
@read, @set, @fast,
Compatibility:
Redis Software and Redis Cloud compatibility

This command works like STTL, but returns the remaining TTL (time to live) of each member in milliseconds instead of seconds.

Required arguments

key

The name of the key that holds the set.

MEMBERS nummembers member [member ...]

The set members to retrieve the remaining TTL for. nummembers is the number of members, followed by that many member names.

Examples

redis> SADD myset member1 member2
(integer) 2
redis> SPEXPIRE myset 300000 MEMBERS 1 member1
1) (integer) 1
redis> SPTTL myset MEMBERS 3 member1 member2 member3
1) (integer) 299993
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

  • Array reply. For each member:
    • Integer reply: -2 if no such member exists in the set, or the key does not exist.
    • Integer reply: -1 if the member exists but has no associated expiration.
    • Integer reply: the TTL in milliseconds.
  • Simple error reply:
    • if parsing failed, mandatory arguments are missing, unknown arguments are specified, or argument values are of the wrong type or out of range.
    • if the key exists but is not a set.

See also

SEXPIRE | SPEXPIRE | SEXPIREAT | SPEXPIREAT | SADDEX | STTL | SEXPIRETIME | SPEXPIRETIME | SPERSIST

RATE THIS PAGE
Back to top ↑