All skills
upstash avatar

/upstash-redis-js

@35da719
by upstashupstash/skills27 stars
7

Work with the @upstash/redis TypeScript/JavaScript SDK, a serverless HTTP-based Redis client for Next.js, Vercel, Cloudflare Workers, edge runtimes, and Node.js. Use when adding a cache (cache-aside, write-through, TTL and expiration strategies), session storage and user sessions, a key-value store, leaderboards and rankings with sorted sets, counters, distributed locks, queues with lists, streams and consumer groups, sparse index-addressed arrays and ring buffers (ARSET, ARINSERT, ARRING, ARGREP, AROP), embeddings and nearest-neighbour vector search stored inside Redis (VECTOR commands via redis.vector, separate from @upstash/vector), JSON documents, pipelines and MULTI/EXEC transactions, Lua scripting, read replicas, or full-text search, typo-tolerant search, facets, aggregations, and search over Redis stream entries with Upstash Redis Search (different from regular FT.SEARCH; also available for TCP clients via @upstash/search-redis and @upstash/search-ioredis). Also use when migrating from ioredis or node-redis, when a Redis connection is needed from a serverless function without connection pooling, when integrating @upstash/ratelimit, or when the user says Redis cache, KV store, session store, serverless Redis, or Upstash Redis. Supports automatic serialization/deserialization of JavaScript types.

Use this Skill: https://skilld.dev/gh/upstash/skills/upstash-redis-js

This session only. Nothing lands on disk.

patternscaching.md

≈338 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Caching Strategies

Overview

Use Redis as a cache layer to reduce database load and improve response times. Supports cache-aside, write-through, and TTL-based expiration.

Good For

  • Reducing database queries
  • Storing frequently accessed data
  • Session data, API responses, computed results
  • Temporary data with automatic expiration

Examples

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

const redis = Redis.fromEnv();

// Cache-Aside (Lazy Loading) - most common pattern
async function getUser(userId: string) {
  // Try cache first
  const cached = await redis.get(`user:${userId}`);

  if (cached) {
    return cached; // Cache hit
  }

  // Cache miss - fetch from database
  const user = await database.users.findById(userId);

  // Store in cache with 1 hour TTL
  await redis.set(`user:${userId}`, user, { ex: 3600 });

  return user;
}

// Write-Through - update cache on write
async function updateUser(userId: string, data: any) {
  // Update database
  const user = await database.users.update(userId, data);

  // Update cache immediately
  await redis.set(`user:${userId}`, user, { ex: 3600 });

  return user;
}

// Cache invalidation
async function deleteUser(userId: string) {
  // Delete from database
  await database.users.delete(userId);

  // Invalidate cache
  await redis.del(`user:${userId}`);
}

Source: SKILL.md on GitHub

1 warningtoday3 checks · Risk SAFE
  • Gen Agent Trust Hubtoday

    The skill provides a comprehensive guide for using the Upstash Redis JavaScript SDK. It follows security best practices for credential management by advocating for environment variables and relies on official vendor resources. While the skill facilitates data ingestion from external databases, it does so as a standard database client with no malicious patterns or unexpected behaviors detected.

  • Sockettoday

    1 alert: gptSecurity

  • Snyktoday

    Risk: LOW · No issues

Signed by skilld at 35da719. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated 2 weeks ago
metadata
{
  "author": "Upstash",
  "homepage": "https://upstash.com"
}

README badge

README badge for upstash/skills/upstash-redis-js