Agent skill · github

upstash-redis

Use Redis over HTTP from serverless and edge runtimes with @upstash/redis, and add rate limiting with @upstash/ratelimit. Use when the user mentions Upstash Redis, needs Redis from a Next.js route handler or middleware, Vercel, Cloudflare Workers, Deno, or Bun without TCP connection pooling, or wants cache-aside with TTLs, a session store, counters, or a 429 rate limiter using fixed window, sliding window, or token bucket. DO NOT use for self-hosted or TCP Redis clients (ioredis, node-redis), Redis Cluster administration, or vector similarity search.

What it needs

About 4k tokens when loaded.

What this skill does

Upstash Redis Skill This skill covers the three things serverless apps most often need Redis for: caching, sessions, and rate limiting. The client talks to Redis over HTTP, so it works where a long-lived TCP connection does not (edge middleware, short lived functions). Follow the steps in order; each ends with a checkpoint. Requirements and limitations An Upstash Redis database (hosted service; usage-based pricing with a free tier). Credentials are a REST URL and token from the database page. Environment variables UPSTASHREDISRESTURL and UPSTASHREDISRESTTOKEN. Every command is an HTTP request. Batch with pipeline() or MGET/MSET when you issue many commands per request; avoid KEYS in production. Values are serialized automatically (objects, arrays, numbers round-trip). Do not JSON.stringify before set or parseInt after get. Step 1 — Install and create one client per module Create the client at module scope, not inside the request handler, so ephemeral caches and pipelines can be reused across invocations. Checkpoint: await redis.ping() returns "PONG". Step 2 — Cache-aside with TTL Always set a TTL on cache entries; namespace keys (user:123, session:abc). Checkpoint: second call to getUser returns without hitting the database and await redis.ttl("user:123") is positive. Step 3 — Sessions with sliding expiration Store the session id in an HttpOnly; Secure; SameSite cookie; never put the Redis token in client code. Checkpoint: getSession after createSession returns the object with userId; after destroySession it returns null. Step 4 — Rate limiting a route handler Identifier: use the user id or API key when authenticated; fall back to IP. Algorithms: Ratelimit.fixedWindow(n, "1 m") (cheapest), slidingWindow (smooth boundaries, default choice), tokenBucket(refill, "10 s", max) (allows bursts). Windows accept ms, s, m, h, d. Tiers: create one Ratelimit per tier with different prefix values. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills github/upstash-redis

View the source on GitHub

Browse the @skills marketplace