Prompt
What should I use if I need TTL and eviction policies?
Latest observation
If you need TTL (time-to-live) and eviction policies, you typically want a cache/data store that supports automatic expiration.
Good options:
-
Redis
Best common choice. Supports:- key TTLs
- multiple eviction policies (LRU, LFU, volatile/allkeys variants)
- very fast in-memory access
-
Memcached
Supports TTL and simple eviction, but with fewer features than Redis. -
Caffeine / Guava Cache (in-process cache for Java)
Great if you need caching inside one application instance. Supports:- expire-after-write / expire-after-access
- size-based eviction
But it’s not a shared distributed cache.
-
Hazelcast / Ignite
If you need a distributed in-memory data grid with TTL/eviction options.
If you mean a database rather than a cache, you’d usually implement TTL yourself or use a database with native TTL support, such as:
- MongoDB (TTL indexes)
- Cassandra (TTL per row/column)
If you want the safest general recommendation: Redis.
If you tell me your language/framework and whether this is local or distributed, I can suggest the best fit.