> ## Documentation Index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Eviction

By default eviction is disabled, and Upstash Redis will reject write operations once the maximum data size
limit has been reached. However, if you are utilizing Upstash Redis as a cache, you
have the option to enable eviction. Enabling eviction allows older data to be
automatically removed from the cache (including Durable Storage) when the maximum size limit is reached.
This ensures that the cache remains within the allocated size and can make room
for new data to be stored. Enabling eviction is particularly useful when the
cache is intended to store frequently changing or temporary data, allowing the
cache to adapt to evolving data needs while maintaining optimal performance.

* You can enable eviction by checking **Eviction** checkbox while creating a new
  database:

  <Frame>
    <img src="https://mintcdn.com/upstash/eu0laKPu7u_-Kw04/img/eviction/create-database.png?fit=max&auto=format&n=eu0laKPu7u_-Kw04&q=85&s=2b8dfc85b0ffbed7aa2e1fa3f50602ab" width="973" height="1062" data-path="img/eviction/create-database.png" />
  </Frame>

* Or for an existing database by clicking **Enable** in Configuration/Eviction
  box in the database details page:
  <Frame>
    <img src="https://mintcdn.com/upstash/eu0laKPu7u_-Kw04/img/eviction/configuration.png?fit=max&auto=format&n=eu0laKPu7u_-Kw04&q=85&s=7239372ec2b89584bc472cb0ea8d8bd0" width="1984" height="548" data-path="img/eviction/configuration.png" />
  </Frame>

Upstash currently uses a single eviction algorithm, called
**optimistic-volatile**, which is a combination of *volatile-random* and
*allkeys-random* eviction policies available in
[the original Redis](https://redis.io/docs/manual/eviction/#eviction-policies).

Initially, Upstash employs random sampling to select keys for eviction, giving
priority to keys marked with a TTL (expire field). If there is a shortage of
volatile keys or they are insufficient to create space, additional non-volatile
keys are randomly chosen for eviction. In future releases, Upstash plans to
introduce more eviction policies, offering users a wider range of options to
customize the eviction behavior according to their specific needs.
