Redis
Serverless Redis over REST and TCP, in one command.
AI/LLM: this page is available in plain markdown at /docs/resources/redis.md
npx extraorbital add redis✓ Provisioned redis/default (us-east-1)
✓ Wrote 3 variables to .env
UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN, REDIS_URLA project that mentions REDIS_URL or either UPSTASH_REDIS_REST_* variable gets
this from extraorbital provision 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
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.
Use it
Over REST, which works in serverless functions and at the edge:
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:
import { createClient } from "redis";
const redis = createClient({ url: process.env.REDIS_URL });
await redis.connect();
await redis.lPush("jobs", JSON.stringify({ id: 1 }));