# Redis

> Serverless Redis over REST and TCP, in one command.

```bash
npx extraorbital add redis
```

```txt
✓ Provisioned redis/default (us-east-1)
✓ Wrote 3 variables to .env

  UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN, REDIS_URL
```

A project that mentions `REDIS_URL` or either `UPSTASH_REDIS_REST_*` variable gets
this from [`extraorbital provision`](/docs/quickstart#how-autopilot-decides) without
naming it.

## What it writes

| Variable | Example |
| --- | --- |
| `UPSTASH_REDIS_REST_URL` | `https://redis.extraorbital.dev/cosmic-otter-default` |
| `UPSTASH_REDIS_REST_TOKEN` | `AX8aACQg…` |
| `REDIS_URL` | `rediss://default:…@redis.extraorbital.dev:6379` |

Two ways in for the same database: an Upstash-compatible REST API for serverless and
edge runtimes, and a standard TCP URL for anything that speaks the Redis protocol.

## Options

```bash
npx extraorbital add redis [--slug <name>] [--region <region>]
```

| Flag | Default | Description |
| --- | --- | --- |
| `--slug` | `default` | A second, fully separate database in the same project |
| `--region` | `us-east-1` | One of `us-east-1`, `eu-central-1`, `ap-southeast-1` |

## Prototype allowance

**256 MB, 500K commands per month and 10 GB of bandwidth free** on the Prototype
plan, counted across your whole account and shared by up to five databases. Past
it, $0.20/100K commands and $0.25/GB-mo — our own cost, with nothing added — on
[a paid plan](/pricing).

## Use it

Over REST, which works in serverless functions and at the edge:

```ts title="cache.ts"
import { Redis } from "@upstash/redis";

const redis = Redis.fromEnv(); // reads UPSTASH_REDIS_REST_URL and _TOKEN

await redis.set("session:brave-fox", { step: 3 }, { ex: 3600 });
const session = await redis.get("session:brave-fox");
```

Or over TCP, with any standard client:

```ts title="queue-worker.ts"
import { createClient } from "redis";

const redis = createClient({ url: process.env.REDIS_URL });
await redis.connect();
await redis.lPush("jobs", JSON.stringify({ id: 1 }));
```

## Next

- [QStash](/docs/resources/qstash) — queues with delivery guarantees over HTTP
- [Pricing](/pricing) — plans, allowances and rates

---

More for agents: [Docs index](https://extraorbital.dev/sitemap.md) · [llms.txt](https://extraorbital.dev/llms.txt) · [agents.md](https://extraorbital.dev/agents.md)
