Search code examples
redisttl

What's default TTL in Redis?


I can't find anywhere online what is default TTL in Redis. I know that I can set TTL for specific SET, but don't know what is default TTL. Can someone tell me what default time to live is in Redis?


Solution

  • The keys with no expiration time set will not expire.

    If you mean TTL command specifically, starting with v2.8, it will return -2 if no EXPIRE value is set.

    Edit: Itamar Haber's comment is true, I recalled false: There is no such setting in redis config for a global TTL. So I deleted the part about that.

    Edit2: Also see the link to the official docs about default expiration of keys here: https://redis.io/commands/expire#appendix-redis-expires