← ClaudeAtlas

ekx-upstash-redislisted

Serverless Redis with Upstash — REST-based client for edge and serverless, rate limiting with @upstash/ratelimit, caching, and session or nonce storage. Use when adding rate limiting to an API route, caching an expensive read, or storing short-lived state that Supabase would be overkill for.
Ekinoxis-evm/claude-skills · ★ 0 · API & Backend · score 60
Install: claude install-skill Ekinoxis-evm/claude-skills
# Upstash Redis Our serverless Redis, with `@upstash/ratelimit` on top of it. Why Upstash and not a normal Redis: it speaks **HTTP**, so it works from Vercel edge and serverless functions where a persistent TCP connection is not available. A regular Redis client opens a connection per invocation and exhausts the connection pool under load — that is the failure `ioredis` has to manage on a long-lived Railway process. --- ## Environment ```bash UPSTASH_REDIS_REST_URL= UPSTASH_REDIS_REST_TOKEN= # SECRET ``` (`UPSTASH_REDIS_REST_KV_REST_API_URL`/`_TOKEN` also turn up — the names Vercel's KV integration injects. Same values; prefer the plain pair.) --- ## Client ```ts import { Redis } from "@upstash/redis"; export const redis = Redis.fromEnv(); // reads the two vars above ``` ```ts await redis.set("price:eth", 3200, { ex: 60 }); // TTL in seconds const price = await redis.get<number>("price:eth"); ``` **Always set a TTL.** Upstash bills per command and per stored byte; keys without expiry accumulate silently and turn into a monthly line item nobody can attribute. --- ## Rate limiting ```ts import { Ratelimit } from "@upstash/ratelimit"; const limiter = new Ratelimit({ redis, limiter: Ratelimit.slidingWindow(10, "60 s"), analytics: true, prefix: "gt", }); export async function POST(req: Request) { const ip = req.headers.get("x-forwarded-for") ?? "anon"; const { success, reset } = await limiter.limit(ip); if (!success) { return new