{
  "schema_version": 2,
  "id": "commands/sttl",
  "title": "STTL",
  "url": "https://redis.io/docs/latest/commands/sttl/",
  "summary": "Returns the TTL in seconds of a set member.",
  "since": "8.12.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-11-23T06:19:08-08:00",
  "page_type": "content",
  "content_hash": "09f513e95e860adde85ed6abf26276b843f82027cf7affce369fbe44e8f47134",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "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.\n\nSee also the [`SPTTL`](https://redis.io/docs/latest/commands/spttl) command, which returns the same information with millisecond resolution."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the set.\n\n</details>\n\n<details open><summary><code>MEMBERS nummembers member [member ...]</code></summary>\n\nThe set members to retrieve the remaining TTL for. `nummembers` is the number of members, followed by that many member names.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> | <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n* [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays). For each member:\n    - [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): `-2` if no such member exists in the set, or the key does not exist.\n    - [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): `-1` if the member exists but has no associated expiration.\n    - [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): the TTL in seconds.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors):\n    - if parsing failed, mandatory arguments are missing, unknown arguments are specified, or argument values are of the wrong type or out of range.\n    - if the key exists but is not a set.\n\n**RESP3:**\n\n* [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays). For each member:\n    - [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): `-2` if no such member exists in the set, or the key does not exist.\n    - [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): `-1` if the member exists but has no associated expiration.\n    - [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): the TTL in seconds.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors):\n    - if parsing failed, mandatory arguments are missing, unknown arguments are specified, or argument values are of the wrong type or out of range.\n    - if the key exists but is not a set."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`SEXPIRE`](https://redis.io/docs/latest/commands/sexpire) | [`SPEXPIRE`](https://redis.io/docs/latest/commands/spexpire) | [`SEXPIREAT`](https://redis.io/docs/latest/commands/sexpireat) | [`SPEXPIREAT`](https://redis.io/docs/latest/commands/spexpireat) | [`SADDEX`](https://redis.io/docs/latest/commands/saddex) | [`SPTTL`](https://redis.io/docs/latest/commands/spttl) | [`SEXPIRETIME`](https://redis.io/docs/latest/commands/sexpiretime) | [`SPEXPIRETIME`](https://redis.io/docs/latest/commands/spexpiretime) | [`SPERSIST`](https://redis.io/docs/latest/commands/spersist)"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "- [Set member expiration](https://redis.io/docs/latest/develop/data-types/sets#member-expiration)"
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "redis",
      "code": "redis> STTL no-key MEMBERS 2 member1 member2\n1) (integer) -2\n2) (integer) -2\nredis> SADD myset member1 member2\n(integer) 2\nredis> SEXPIRE myset 300 MEMBERS 2 member1 member3\n1) (integer) 1\n2) (integer) -2\nredis> STTL myset MEMBERS 3 member1 member2 member3\n1) (integer) 300\n2) (integer) -1\n3) (integer) -2",
      "section_id": "examples"
    }
  ]
}
