▲ | motorest 9 hours ago | ||||||||||||||||||||||
> If we don't use a TTL, aren't we going to have to either accept that our cache will grow without bounds (...) Do you have a bound? I mean, with Redis you do, but that's primarily a cost-driven bound. Nevertheless, I think you're confusing the point of a TTL. TTLs are not used to limit how much data you cache. The whole point of a TTL is to be able to tell whether a cache entry is still fresh or it is stale and must be revalidated. Just because some cache strategies use TTL to determine what entry they should evict, that is just a scenario that takes place when memory is at full capacity. | |||||||||||||||||||||||
▲ | maxbond 9 hours ago | parent [-] | ||||||||||||||||||||||
A TTL doesn't really tell you if it's stale though. It gives you an upper bound on how long it can have been stale. But something becomes stale when the underlying resource is written to, which can happen an hour or an instant after you cache it. You should probably evict it when the write comes in. In my mind, it's for evicting things that aren't in use (to free up memory). | |||||||||||||||||||||||
|