Database / REDIS
Why should you configure an eviction policy for a Redis instance used as a cache?
The default noeviction policy means once maxmemory is reached, Redis starts rejecting new write commands outright with an out-of-memory error, rather than making room by removing older data. For a pure caching use case, that's usually the wrong behavior: a cache is supposed to gracefully lose its least valuable entries under memory pressure, not stop accepting new data and start returning errors to the application.
maxmemory 2gb maxmemory-policy allkeys-lru
Configuring an eviction policy like allkeys-lru or allkeys-lfu makes the cache self-managing: as memory fills up, Redis automatically removes the least recently (or least frequently) used entries to make room, which matches how a cache is expected to behave — stale or unused data quietly falls out, while hot data stays resident. Skipping this configuration is a common cause of production incidents where a cache-only Redis instance unexpectedly starts throwing write errors under load, simply because nobody told it that eviction, not rejection, was the intended behavior when full.
More Related questions...
