CodePark/ questions / TTL & eviction policies
START PRACTICINGPRACTICE
Backend question · Redis & caching › TTL & eviction policies

TTL session:abc returns -1. What does that mean?

The key exists but has no expiry

TTL returns -1 when the key exists but has no expiry. It returns -2 when the key does not exist, so "The key does not exist" is wrong.

Mixing up these two values is a common bug when you check whether a session was saved with a TTL.