Senior
What happens when Redis memory runs out?
sobes.tech AI
Answer from AI
When Redis runs out of available memory, the behavior depends on the configuration settings, particularly the maxmemory-policy parameter. Redis will not automatically increase memory but will apply one of the memory management strategies:
- noeviction (default) — new entries will not be added if memory is full, and Redis will return an error.
- allkeys-lru — removes the least recently used keys among all keys.
- volatile-lru — removes the least recently used keys with an expiration time (TTL).
- allkeys-random — removes random keys.
- volatile-random — removes random keys with TTL.
- volatile-ttl — removes keys with the nearest TTL expiration.
If no eviction policy is set, Redis will stop accepting new entries and return an error. It is important to choose the correct strategy depending on the use case to avoid losing important data or causing application failures.