본문으로 건너뛰기
Skillpedia
데이터베이스48k · #6072

upstash-redis

하는 일

직접 연결을 지원하지 않는 환경에서도 Upstash Redis를 사용해 데이터를 빠르게 저장하고 불러오도록 합니다. 중요한 정보를 담는 빠른 '금고'와 비슷합니다.

사용하는 경우

  • ✓임시 정보(캐시)를 저장해야 할 때.
  • ✓웹사이트에서 사용자 세션을 관리하고 싶을 때.
  • ✓방문이나 클릭 같은 이벤트를 세고 싶을 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/upstash-redis/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/upstash-redis/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“사용자 이름 'Maria'를 'user:123' 키로 저장하고, 1시간 뒤에 만료되도록 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

애플리케이션은 인터넷 요청을 통해 데이터를 Upstash Redis로 보냅니다. Upstash Redis는 이 데이터를 저장하고, 애플리케이션이 요청하면 돌려줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Upstash Redis

Overview

@upstash/redis is a Redis client that talks to an Upstash Redis database over HTTPS instead of a TCP connection. Because every command is a stateless HTTP request, it works in environments where a pooled TCP client is awkward or impossible: Vercel and Netlify functions, Cloudflare Workers, Deno, Bun, and Next.js middleware. The client serializes and deserializes JavaScript values automatically, so numbers and objects round-trip without manual JSON.parse.

When to Use This Skill

  • Use when the user needs a cache, session store, counter, leaderboard, or simple queue from a serverless or edge function.
  • Use when the user mentions Upstash Redis, UPSTASH_REDIS_REST_URL, or @upstash/redis.
  • Use when migrating an ioredis or node-redis call site to a runtime that cannot hold a persistent TCP socket.
  • Do not use for a self-hosted or non-Upstash Redis server; the client only speaks the Upstash REST protocol. Use ioredis or node-redis there.
  • Do not use for Redis administration or CLI work; see redis-cli.

How It Works

Step 1: Configure credentials

Create a database in the Upstash console and copy the REST URL and token into environment variables. Never hardcode them.

UPSTASH_REDIS_REST_URL=https://<your-db>.upstash.io
UPSTASH_REDIS_REST_TOKEN=<your-rest-token>

Step 2: Create one client per module

import { Redis } from "@upstash/redis";

export const redis = Redis.fromEnv();

On Cloudflare Workers, import from @upstash/redis/cloudflare and pass the worker env object: Redis.fromEnv(env).

Step 3: Call Redis commands as methods

Command names are lowercase methods (get, set, hset, zadd, incr). Values are auto-serialized; pass and receive native JavaScript types.

Examples

Example 1: Cache-aside with a TTL

import { Redis } from "@upstash/redis";

const redis = Redis.fromEnv();

export async function getUser(id: string) {
  const cached = await redis.get<{ id: string; name: string }>(`user:${id}`);
  if (cached) return cached;

  const user = await db.users.findById(id);
  await redis.set(`user:${id}`, user, { ex: 3600 }); // expires in 1 hour
  return user;
}

export async function invalidateUser(id: string) {
  await redis.del(`user:${id}`);
}

Example 2: Batch commands in a pipeline

const pipeline = redis.pipeline();
pipeline.hset("user:1", { name: "Alice", plan: "pro" });
pipeline.incr("signups:total");
pipeline.zadd("leaderboard", { score: 120, member: "user:1" });
const [hsetResult, signups, zaddResult] = await pipeline.exec();

pipeline() batches independent commands into one round trip. It is not atomic; use redis.multi() for MULTI/EXEC or a reviewed server-side Lua script when commands must run as one unit.

Best Practices

  • ✅ Read credentials with Redis.fromEnv() or from a secrets manager.
  • ✅ Set a TTL ({ ex: seconds }) on cache entries so stale data expires.
  • ✅ Namespace keys (user:123, session:abc) to keep the keyspace readable.
  • ✅ Use pipeline() or mget/mset instead of many sequential awaits.
  • ❌ Don't JSON.stringify values before set; the client already does it.
  • ❌ Don't call keys("*") in request handlers; use scan for large keyspaces.
  • ❌ Don't store secrets or PII in Redis without a retention plan and TTL.

Limitations

  • Requires an Upstash Redis database; it cannot connect to other Redis servers.
  • Each command is an HTTP request, so latency is higher than a warm TCP connection; batch with pipelines where it matters.
  • Transactions (multi()) do not roll back on runtime errors, and WATCH is not available over REST; use a Lua script for atomic check-and-set.
  • Pub/Sub subscribe and blocking commands (BLPOP, XREAD BLOCK) are not supported over the REST client.
  • This skill covers the TypeScript client only. Python, Go, and other SDKs differ in method names.
  • This skill does not replace environment-specific validation, testing, or expert review.

Security & Safety Notes

  • The REST token grants full read/write access to the database. Keep it in server-side environment variables; never ship it to a browser bundle.
  • Use a read-only token from the console for read-only workloads.
  • Commands such as flushdb and del are destructive; confirm with the user before running them against a production database.

Common Pitfalls

…

자주 묻는 질문

일반 데이터베이스 대신 Upstash Redis를 쓰는 이유는 무엇인가요?

매우 빠르도록 최적화되어 있고, 오래 유지되는 연결을 잘 다루지 못하는 최신 프로그래밍 환경(서버리스, 엣지)에서 잘 작동합니다.

'키'와 '값'은 무엇인가요?

'키'는 파일 이름, '값'은 그 파일의 내용과 비슷하게 생각하면 됩니다. 키로 값을 찾아 가져옵니다.

어떤 종류의 정보든 저장할 수 있나요?

네, 텍스트, 숫자, 그리고 객체 같은 복잡한 데이터 구조도 저장할 수 있습니다. 변환은 시스템이 자동으로 처리합니다.

상세 정보

작성자의 원본 설명

Use the @upstash/redis HTTP client for caching, sessions, counters, and Redis data structures from serverless and edge runtimes without connection pooling.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#6072
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬