---
title: "Redis Eviction Policies"
sidebar_label: "Eviction policies"
sidebar_position: 4
description: "List of Redis eviction policies and how to change the policy"
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import {TabItemLabel} from '@selectel/docux/components';
import Formbricks from '@theme/MDXComponents/Formbricks';
import {CustomTable} from '@selectel/docux/components';

# Redis Eviction Policies

An eviction policy is a rule that Redis uses to evict keys to free up memory when memory consumption reaches the specified [limit](#key-storage-memory-limit). Learn more about eviction policies in the [Key eviction](https://redis.io/docs/latest/develop/reference/eviction/) section of the Redis documentation.

You can view the [list of eviction policies](#eviction-policies-list).

You can select an eviction policy when [creating a cluster](/managed-databases/redis/create-cluster.mdx) or [change it](#edit-eviction-policy) in an existing cluster.

## Memory limit for key storage \{#key-storage-memory-limit}

The memory limit for storing keys is set by the `maxmemory` parameter. The default `maxmemory` value is 75% of the RAM on the cluster node. The remaining 25% is strictly reserved for Redis internal mechanisms.

You can change the `maxmemory` value only in Redis [version](/managed-databases/redis/configurations.mdx#versions) 8:

* when [creating a cluster](/managed-databases/redis/create-cluster.mdx);
* or when [changing the eviction policy](#edit-eviction-policy) in an existing cluster.

You can change this value within the range of 1% to 75%. If you set a value lower than 75%, the remaining memory can be used by Redis internal mechanisms.

## List of eviction policies \{#eviction-policies-list}

<CustomTable>
  <table>
    <tbody>
      <tr>
        <th>noeviction</th>

        <td>
          Does not evict keys when the limit specified in `maxmemory` is reached. New write operations will fail due to insufficient memory
        </td>
      </tr>

      <tr>
        <th>volatile-lru</th>

        <td>
          Evicts keys with a set Time To Live (TTL) that have not been accessed for a long time. Keys are evicted according to the [approximate LRU algorithm](https://redis.io/docs/latest/develop/reference/eviction/#apx-lru)
        </td>
      </tr>

      <tr>
        <th>volatile-lfu</th>

        <td>
          Evicts keys with a TTL that have been accessed the least since the TTL was set. Keys are evicted according to the [approximate LFU algorithm](https://redis.io/docs/latest/develop/reference/eviction/#lfu-eviction)
        </td>
      </tr>

      <tr>
        <th>volatile-ttl</th><td>Evicts keys with the shortest remaining TTL</td>
      </tr>

      <tr>
        <th>volatile-random</th><td>Evicts random keys with TTL</td>
      </tr>

      <tr>
        <th>allkeys-lru</th>

        <td>
          Evicts any keys that have not been accessed for a long time. Keys are evicted according to the [approximate LRU algorithm](https://redis.io/docs/latest/develop/reference/eviction/#apx-lru)
        </td>
      </tr>

      <tr>
        <th>allkeys-lfu</th>

        <td>
          Evicts any keys that have been accessed the least since they were created. Keys are evicted according to the [approximate LFU algorithm](https://redis.io/docs/latest/develop/reference/eviction/#lfu-eviction)
        </td>
      </tr>

      <tr>
        <th>allkeys-random</th><td>Evicts any random keys</td>
      </tr>
    </tbody>
  </table>
</CustomTable>

## Change the Eviction policy \{#edit-eviction-policy}

:::info

We recommend changing the policy only if you are sure about the consequences — there is a possibility of partial data loss.

:::

<Tabs queryString="edit-eviction-policy">
  <TabItem value="redis-6" default>
    <TabItemLabel>
      Redis 6
    </TabItemLabel>

    1. In the [Dashboard](https://my.selectel.ru/vpc/default/dbaas/), on the top menu, click **Products** and select **Managed Databases**.
    2. In the **Databases** section, open the **Active** tab.
    3. Open the cluster page → **Settings** tab.
    4. In the **Eviction Policy** block, click **Change**.
    5. In the **Maxmemory Policy** field, select an eviction policy.
    6. Click **Save**.
  </TabItem>

  <TabItem value="redis-8">
    <TabItemLabel>
      Redis 8
    </TabItemLabel>

    1. In the [Dashboard](https://my.selectel.ru/vpc/default/dbaas/), on the top menu, click **Products** and select **Managed Databases**.
    2. In the **Databases** section, open the **Active** tab.
    3. Open the cluster page → **Settings** tab.
    4. In the **Eviction Policy** block, click **Change**.
    5. In the **Maxmemory** field, specify the parameter value. The available values are from 1% to 75%.
    6. In the **Maxmemory Policy** field, select an eviction policy.
    7. Click **Save**.
  </TabItem>
</Tabs>

<Formbricks />
