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.

searchadapters.md

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

Adapters

Overview

@upstash/redis works over HTTP, which is ideal for serverless environments. If you need TCP-based connections (e.g., long-running servers with redis or ioredis), use the adapter packages @upstash/search-redis and @upstash/search-ioredis. They provide the exact same search API.

Packages

Package Client Protocol Install
@upstash/redis Built-in HTTP/REST npm install @upstash/redis
@upstash/search-redis node-redis TCP npm install @upstash/search-redis redis
@upstash/search-ioredis ioredis TCP npm install @upstash/search-ioredis ioredis

Examples

With @upstash/redis (HTTP)

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

const redis = Redis.fromEnv();

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

const results = await index.query({
  filter: { name: { $eq: "laptop" } },
  select: { name: true, price: true },
});

With node-redis (TCP)

import { createClient } from "redis";
import { createSearch, s } from "@upstash/search-redis";

const client = createClient({ url: process.env.REDIS_URL });
await client.connect();

const search = createSearch(client);

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

const results = await index.query({
  filter: { name: { $eq: "laptop" } },
  select: { name: true, price: true },
});

await client.disconnect();

With ioredis (TCP)

import IORedis from "ioredis";
import { createSearch, s } from "@upstash/search-ioredis";

const ioredis = new IORedis(process.env.REDIS_URL);

const search = createSearch(ioredis);

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

const results = await index.query({
  filter: { name: { $eq: "laptop" } },
  select: { name: true, price: true },
});

await ioredis.disconnect();

API Parity

All three packages expose identical search APIs:

  • search.createIndex() / createSearch(client).createIndex()
  • search.index() / createSearch(client).index()
  • search.alias.list(), search.alias.add(), search.alias.delete()
  • index.query(), index.aggregate(), index.count()
  • index.describe(), index.drop(), index.waitIndexing()
  • index.addAlias()

The only difference is initialization. The s schema builder is re-exported from all packages.

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

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

README badge

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