---
title: "Managed Redis cache (Valkey): the while.sh docs"
url: https://while.sh/en/docs/building-blocks/valkey/
updated: 2026-11-09
---

# Valkey cache (Redis)

An in-memory cache that speaks the Redis protocol, for your sessions, your counters or a job queue. Any Redis client works.

> You, to your agent: Add a Redis cache for the sessions.

## What your agent writes

Your agent writes it in while.yaml, at the root of your app:

```yaml titre="while.yaml"
caches:
  - name: sessions
    memory: 64Mi
  - name: jobs
    memory: 256Mi
    durable: true
```

## What your app receives

Your app receives these environment variables at every deployment:

| Variable | What it holds |
|---|---|
| `REDIS_URL` | The address of the first cache, password included. |
| `CACHE_SESSIONS_URL` | The address of the sessions cache, under the cache's name. |
| `CACHE_SESSIONS_PASSWORD` | Its password. |

## When to use it

For a cache, sessions or a counter, anything that can be rebuilt. With `durable: true`, it also serves as a task queue. What must be kept goes in a database.

## How it works

A Valkey cache keeps your data in memory and speaks the Redis protocol: any Redis client works. Its password is included in `REDIS_URL`.

## What to know

A cache has a single copy. By default, nothing is kept on disk: a restart empties the cache, and when memory is full, the least used keys go. With `durable: true`, the data is journaled on disk and never evicted: when memory is full, writes are refused.

## Pricing

These prices are the same on every plan, excluding VAT:

| Resource | Price | Details |
|---|---|---|
| CPU and memory | €17 per vCPU·month and €8.50 per GiB·month | apps by usage, caches by reservation |
| Volumes | €0.15 per GiB·month | the disk of a durable cache |

## Guides

- [Add a Redis-compatible cache to your app, from your AI agent](/en/guides/add-redis-cache/)
- [Run a background worker with BullMQ, Celery or Sidekiq, from your AI agent](/en/guides/background-worker-queue/)
