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.

searchcommandsaliases.md

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

Aliases

Overview

Index aliases provide an indirection layer between your application and the actual index. You can point an alias to any index and swap it atomically, enabling zero-downtime reindexing.

Good For

  • Zero-downtime index rebuilds (blue/green reindexing)
  • A/B testing different index configurations
  • Versioned index management

Examples

Add an Alias

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

const redis = Redis.fromEnv();

// Create an index
const index = await redis.search.createIndex({
  name: "products-v1",
  prefix: "product:",
  dataType: "json",
  schema: s.object({ name: s.string(), price: s.number("F64") }),
});

// Add alias via the index instance
await index.addAlias({ alias: "products" });

// Or via the redis.search.alias API
await redis.search.alias.add({ indexName: "products-v1", alias: "products" });

List All Aliases

const aliases = await redis.search.alias.list();
// { "products": "products-v1", "users": "users-v2" }

Delete an Alias

await redis.search.alias.delete({ alias: "products" });
// Returns 1 if deleted, 0 if alias didn't exist

Zero-Downtime Reindexing

// 1. Resolve the alias's current target before swapping
const aliases = await redis.search.alias.list();
const oldIndexName = aliases["products"]; // "products-v1"

// 2. Create new index with updated schema
const newIndex = await redis.search.createIndex({
  name: "products-v2",
  prefix: "product:",
  dataType: "json",
  schema: s.object({
    name: s.string(),
    price: s.number("F64"),
    description: s.string(), // new field
  }),
});

// 3. Wait for new index to finish scanning existing keys
await newIndex.waitIndexing();

// 4. Atomically swap the alias to the new index
// (addAlias updates the alias if it already exists)
await redis.search.alias.add({ indexName: "products-v2", alias: "products" });

// 5. Drop the old index by name
const oldIndex = redis.search.index({ name: oldIndexName });
await oldIndex.drop();

After step 4 the alias resolves to products-v2, so dropping by the alias name would drop the new index — resolve it before the swap.

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 5 days ago.

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

README badge

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