मुख्य सामग्री पर जाएँ
Skillpedia
डेटाबेस48k · #6072

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 पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/upstash-redis/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

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 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 ही क्यों इस्तेमाल करें, सामान्य डेटाबेस क्यों नहीं?

यह बहुत तेज़ चलने के लिए बनाया गया है और आधुनिक प्रोग्रामिंग वातावरण (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.

repo: sickn33/agentic-awesome-skills

लोकप्रियता

GitHub स्टार
48k
रैंकिंग में स्थान
#6072
लाइसेंस
MIT
अपडेट की गई
15/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

00-andruia-consultant

48k

आपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।

AI और एजेंटएजेंट

007

48k

आपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।

कोडिंगसिक्योरिटी

10-andruia-skill-smith

48k

आपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।

AI और एजेंटएजेंट

20-andruia-niche-intelligence

48k

आपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।

लेखन और डॉक्यूमेंटरिसर्च

मिलती-जुलती skills