---
title: Change Eviction Policy
url: https://docs.vultr.com/products/storage/databases/valkey/management/settings/change-eviction-policy
description: Learn how to modify the eviction policy for your Vultr Managed Database for Valkey to control memory usage and data persistence.
publish_date: 2024-09-23T20:21:52.926714Z
last_updated: 2026-05-26T19:44:05.541266Z
---

# How to Manage Eviction Policy for Vultr Managed Database for Valkey

An eviction policy is an algorithm that determine the keys to remove when the database reaches the maximum memory limit. By default, Vultr sets `noeviction` eviction policy. Eviction aims to make room for new data and to prevent unexpected behavior from your applications, always choose a large database plan that can handle your data. Follow this guide to manage Vultr Managed Database for Valkey eviction policy.

=== "Vultr Console"

    1. Navigate to **Products** and select **Databases**.
    1. Click the target database instance.
    1. Navigate to **Settings** then **Eviction Policies**. 
    1. Choose your preferred eviction policy and click **Save**.

=== "Vultr API"

    1. List all the database instances by sending a `GET` request to the [**List Managed Databases** endpoint](https://www.vultr.com/api/#tag/managed-databases/operation/list-databases) and note the database ID. For example, `43b4c774-5dff-4ac0-a01f-78a23c2205b5`.

        ```console
        $ curl "https://api.vultr.com/v2/databases" \
            -X GET \
            -H "Authorization: Bearer ${VULTR_API_KEY}"
        ```

    1. Send a `PUT` request to the [**Update Managed Database** endpoint](https://www.vultr.com/api/#tag/managed-databases/operation/update-database) specifying the database ID to change the eviction policy.

        ```console
        $ curl "https://api.vultr.com/v2/databases/database_id" \
            -X PUT \
            -H "Authorization: Bearer ${VULTR_API_KEY}" \
            -H "Content-Type: application/json" \
            --data '{
                "eviction_policy" : "volatile-lru"
            }'
        ```

        Visit the [**Update Managed Database** endpoint](https://www.vultr.com/api/#tag/managed-databases/operation/update-database) to view additional attributes to add to your request.

=== "Vultr CLI"

    1. [Install and configure the Vultr CLI](https://github.com/vultr/vultr-cli#installation).
    1. List all database instances and note the database ID. For instance, `d6ac2a3c-92ea-43ef-8185-71a23e58ad8c`.

        ```console
        $ vultr-cli database list --summarize
        ```

    1. Run the following command to change the eviction policy and specify the database ID.

        ```console
        $ vultr-cli database update database_id \
        --eviction-policy "volatile-lru"
        ```
        
        Run `vultr-cli database update --help` to view all options.

=== "Terraform"

    1. Open your Terraform configuration for the existing Managed Database for Valkey resource.

    1. Add or update the `eviction_policy` argument to set the data eviction policy.

        ```terraform
        resource "vultr_database" "valkey" {
            # ...existing fields (database_engine, region, plan, label, etc.)
            
            eviction_policy = "volatile-lru"
        }
        ```

    1. Apply and observe the following output:

        ```
        Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
        ```
