upstash-redis
यह क्या करती है
यह ऐप्लिकेशन को Upstash Redis की मदद से डेटा तेज़ी से सेव और वापस लाने देता है, भले ही वह वातावरण सीधे कनेक्शन को सपोर्ट न करता हो। यह किसी ज़रूरी जानकारी के लिए एक तेज़ 'तिजोरी' की तरह काम करता है।
कब इस्तेमाल करें
- ✓जब आपको अस्थायी जानकारी (cache) स्टोर करनी हो।
- ✓वेबसाइट पर यूज़र सेशन मैनेज करने के लिए।
- ✓विज़िट या क्लिक जैसी घटनाओं को गिनने के लिए।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/upstash-redis/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“यूज़रनेम 'Maria' को ID 'user:123' के साथ सेव करो और इसे 1 घंटे में expire हो जाने दो।”
हर हफ़्ते 5 नई skills, 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
ioredisornode-rediscall 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
ioredisornode-redisthere. - 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()ormget/msetinstead of many sequential awaits. - ❌ Don't
JSON.stringifyvalues beforeset; the client already does it. - ❌ Don't call
keys("*")in request handlers; usescanfor 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, andWATCHis 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
flushdbanddelare destructive; confirm with the user before running them against a production database.
Common Pitfalls
…
अक्सर पूछे जाने वाले सवाल
Upstash Redis ही क्यों इस्तेमाल करें, सामान्य डेटाबेस क्यों नहीं?
यह बहुत तेज़ चलने के लिए बनाया गया है और आधुनिक प्रोग्रामिंग वातावरण (serverless/edge) में अच्छी तरह काम करता है, जहाँ लंबे समय तक चलने वाले कनेक्शन ठीक से नहीं संभाले जाते।
'keys' और 'values' क्या होते हैं?
'Keys' को फाइल के नाम और 'values' को उस फाइल की सामग्री समझिए। Key से आप value ढूंढकर वापस पा सकते हैं।
क्या किसी भी तरह की जानकारी स्टोर की जा सकती है?
हाँ, आप टेक्स्ट, नंबर और objects जैसे जटिल डेटा स्ट्रक्चर भी स्टोर कर सकते हैं। बदलने का काम सिस्टम अपने-आप कर देता है।
जानकारी
लेखक का मूल विवरण
Use the @upstash/redis HTTP client for caching, sessions, counters, and Redis data structures from serverless and edge runtimes without connection pooling.
लोकप्रियता
- GitHub स्टार
- 48k
- रैंकिंग में स्थान
- #6072
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
discrawl
394kयह आपके एजेंट को Discord संदेशों के सेव किए गए स्थानीय आर्काइव में खोजने, उसका सारांश बनाने और उसकी ताज़गी जांचने में मदद करती है।
clickhouse-io
280kआपके एजेंट को ClickHouse databases में queries और schemas optimize करने में मदद करता है। high-performance analytical workloads के लिए best practices लागू करता है। जब analytical queries बहुत धीमी हों, तब इसका उपयोग करें।
scientific-db-pubmed-database
280kआपके एजेंट को बायोमेडिकल क्षेत्र के वैज्ञानिक लेख खोजने में मदद करता है। जिस रिसर्च में खास मेडिकल जानकारी चाहिए, उसके लिए यह काम का है।