# Redis recipe

URL: https://briq.cloud/cookbook/redis

> A Redis server (Valkey-compatible) for caches and queues.

Tags: cache, queue

Guides:

- [Run tests against real services](https://briq.cloud/docs/guides/run-tests-against-real-services.md): Replace mocks with a real Postgres and Redis for the duration of a test run.
- [Connect to a database from outside](https://briq.cloud/docs/guides/connect-to-a-database-from-outside.md): A briq's database reachable from psql, a BI tool or an app elsewhere, over TLS, with a normal connection string.

## Run it

MCP:

```ts
briq_run({
  recipe: "redis",
  params: {
    "version": "7",
    "size": "nano"
  },
  wait: true
})
```

REST:

```bash
curl -X POST https://api.briq.cloud/v1/briqs \
  -H "Authorization: Bearer $BRIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "recipe": "redis",
    "params": {
      "version": "7",
      "size": "nano"
    },
    "wait": true
  }'
# → { "briqs": [{ "id": "bq_…", … }], "outputs": { "REDIS_URL": "…" }, … }

# ... when done, for each briq id
curl -X DELETE https://api.briq.cloud/v1/briqs/<id> \
  -H "Authorization: Bearer $BRIQ_API_KEY"
```

## Parameters

| Name | Type | Options | Default | What it does |
| --- | --- | --- | --- | --- |
| `version` | enum | 7 | "7" | — |
| `size` | enum | nano, small, medium, large | "nano" | — |

## Outputs

Returned by `briq_run` once the stack is healthy. Hosts resolve inside your team network; secrets are generated per run.

| Output | Value |
| --- | --- |
| `REDIS_URL` | `redis://default:<REDIS_PASSWORD>@redis.<stack>.internal:6379` |
| `REDIS_PASSWORD` | `<REDIS_PASSWORD>` |

## What it runs

| Briq | Image | Ports | Size | Volume |
| --- | --- | --- | --- | --- |
| redis | `redis:7-alpine` | 6379 | nano | — |

## When to use it

* Your app or worker expects `REDIS_URL`: caching, sessions, rate limiting, queues.
* You are testing BullMQ, Sidekiq-style or Celery-style workers against a real broker.

## Tips

* **A password, no volume.** `REDIS_URL` carries the password. Redis saves to its disk when it
  stops, so data usually survives a stop, but keep nothing there you cannot rebuild.
* **Pair it with the app in one stack** and pass `REDIS_URL` to it.
* **Inspect it** with `briq_exec`: `["sh", "-c", "REDISCLI_AUTH=$REDIS_PASSWORD redis-cli info memory"]`.
* **Connect from outside**: `briq_expose` port 6379 with `protocol: "redis"` gives a `rediss://`
  URL. `redis-cli` needs `--tls --sni <host>`. See [Connect to a database from outside](https://briq.cloud/docs/guides/connect-to-a-database-from-outside).
* **Queues with a UI**: [`redis-bullmq`](https://briq.cloud/cookbook/redis-bullmq).
