---
title: "What are Redis Memory Eviction Policies and how do you choose the right one?"  
description: "What are Redis Memory Eviction Policies and how do you choose the right one?"  
author: "John Smith"  
published: 2026-09-17  
updated: 2026-10-12  
canonical: https://answers.mindstick.com/qa/117199/what-are-redis-memory-eviction-policies-and-how-do-you-choose-the-right-one  
category: "Redis"  
tags: ["Redis", "Caching", "Database Administration"]  
reading_time: 3 minutes  

---

# What are Redis Memory Eviction Policies and how do you choose the right one?

When Redis reaches its maximum allocated memory limit defined by the `maxmemory` configuration setting, it invokes an eviction policy to determine which keys should be removed to make room for new write operations.

### Key Eviction Strategies

- **allkeys-lru**: Evicts the least recently used keys across all keys, regardless of TTL settings.
- **volatile-lru**: Evicts least recently used keys that have an explicit expiration time configured.
- **noeviction**: Returns write errors when memory capacity is reached (default policy).

You can configure the active **maxmemory-policy** dynamically using Redis CLI parameters:

```sql
-- Set maximum memory cap to 2 Gigabytes
CONFIG SET maxmemory 2gb

-- Change memory eviction policy to volatile-lru
CONFIG SET maxmemory-policy volatile-lru

-- Inspect current maxmemory-policy setting
CONFIG GET maxmemory-policy
```

## Answers

### Answer by Austin Dcruz

Redis eviction policies determine what happens when its memory use reaches the configured `maxmemory` limit. Depending on the policy, Redis may remove eligible keys to make room for new data—or reject writes that need more memory.

## The available policies

- **`noeviction`:** Redis does not remove keys. Reads continue, but writes that require additional memory fail once the limit is reached.
- **`allkeys-lru`:** Evicts keys that appear least recently used, whether or not they have an [expiration time](https://www.mindstick.com/interview/34196/how-can-you-configure-forms-authentication-to-expire-after-a-certain-time-or-use-sliding-expiration).
- **`volatile-lru`:** Applies the same least-recently-used approach, but only to keys with an expiration time.
- **`allkeys-lfu`:** Evicts keys that appear least frequently used, from the full keyspace.
- **`volatile-lfu`:** Uses frequency to choose among keys that have an expiration time.
- **`allkeys-random` and `volatile-random`:** Evict a random key from the full keyspace or from expiring keys, respectively.
- **`volatile-ttl`:** Evicts expiring keys with the shortest remaining time to live first.

LRU and LFU are approximations, not perfect records of every access. LRU suits workloads where recently used data is likely to be used again. LFU can be a better fit when a relatively small group of keys stays popular over time, even if those keys are not accessed every moment.

## How to choose

For a cache where any entry can be rebuilt, `allkeys-lru` is a sensible starting point. Consider `allkeys-lfu` when access frequency matters more than recency. Random eviction can work for workloads where keys are similarly valuable and tracking access patterns offers little benefit.

Choose a `volatile-*` policy when keys without expiration times must be protected from eviction. Keep in mind that if no keys have a TTL, there may be nothing eligible to evict; Redis can then reject memory-consuming writes, much like it does under `noeviction`. `volatile-ttl` makes sense when short-lived entries should be sacrificed before entries with more time remaining.

If Redis holds data that cannot simply be recreated, eviction may mean losing data, so `noeviction` can be safer—but your application must handle write errors and [memory limit](https://www.mindstick.com/interview/34328/how-would-you-limit-memory-use-when-paginating-a-large-object-store-result-set)s. In every case, test against a representative workload and monitor memory use and eviction counts rather than choosing by policy name alone.


---

Original Source: https://answers.mindstick.com/qa/117199/what-are-redis-memory-eviction-policies-and-how-do-you-choose-the-right-one

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
