STTL
STTL 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
Returns the remaining TTL (time to live), in seconds, of one or more set members that have an expiration. Use it to check how many more seconds a member stays in the set.
See also the SPTTL command, which returns the same information with millisecond resolution.
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> STTL no-key MEMBERS 2 member1 member2
1) (integer) -2
2) (integer) -2
redis> SADD myset member1 member2
(integer) 2
redis> SEXPIRE myset 300 MEMBERS 2 member1 member3
1) (integer) 1
2) (integer) -2
redis> STTL myset MEMBERS 3 member1 member2 member3
1) (integer) 300
2) (integer) -1
3) (integer) -2
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ❌ Standard |
❌ Standard |
Return information
- Array reply. For each member:
- Integer reply:
-2if no such member exists in the set, or the key does not exist. - Integer reply:
-1if the member exists but has no associated expiration. - Integer reply: the TTL in seconds.
- Integer reply:
- 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 | SPTTL | SEXPIRETIME | SPEXPIRETIME | SPERSIST