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.

data-structuresstrings.md

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

Strings

Overview

Strings are the most basic Redis data structure. They store a single value and support atomic operations like increment/decrement.

Good For

  • Caching simple values (strings, numbers, booleans, objects)
  • Counters (page views, likes, inventory)
  • Feature flags
  • Session tokens

Limitations

  • Maximum value size: 512 MB
  • No built-in list or set operations on a single key
  • Increment/decrement only work on values that can be parsed as integers

Examples

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

const redis = Redis.fromEnv();

// Set and get strings
await redis.set("greeting", "Hello World");
const greeting = await redis.get("greeting"); // "Hello World"

// Set and get numbers (automatic serialization)
await redis.set("views", 100);
const views = await redis.get("views"); // 100 (as number, not string)

// Set and get objects (automatic JSON serialization)
await redis.set("user", { name: "Alice", age: 30 });
const user = await redis.get("user"); // { name: "Alice", age: 30 }

// Set with expiration (TTL in seconds)
await redis.setex("session", 3600, { userId: "123" });

// Set only if key doesn't exist
await redis.setnx("lock", "process-1"); // Returns 1 if set, 0 if already exists

// Increment and decrement counters
await redis.incr("views"); // 101
await redis.decr("views"); // 100
await redis.incrby("views", 10); // 110
await redis.decrby("views", 5); // 105

// Append to string
await redis.set("name", "Alice");
await redis.append("name", " Smith"); // "Alice Smith"

// Get and set atomically
const oldValue = await redis.getset("counter", 0);

// Multiple get/set (batch operations)
await redis.mset({ key1: "value1", key2: "value2", key3: 123 });
const values = await redis.mget("key1", "key2", "key3"); // ["value1", "value2", 123]

// Check if key exists
const exists = await redis.exists("greeting"); // 1 if exists, 0 if not

// Delete key
await redis.del("greeting");

// Get TTL (time to live in seconds)
await redis.ttl("session"); // seconds remaining, -1 if no expiry, -2 if doesn't exist

// Set expiration on existing key
await redis.expire("key1", 60); // expires in 60 seconds

Source: SKILL.md on GitHub

1 warning10d3 checks · Risk SAFE
  • Gen Agent Trust Hub10d

    The skill provides a comprehensive set of documentation and code examples for using the Upstash Redis SDK. It covers various data structures, performance optimizations, and search capabilities. No malicious code, obfuscation, or unauthorized data access patterns were detected. The skill uses standard environment variables for secret management and references official Upstash packages.

  • Socket10d

    1 alert: gptSecurity

  • Snyk10d

    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