upstash

📁 upstash/com 📅 13 days ago
1
总安装量
1
周安装量
#55282
全站排名
安装命令
npx skills add https://upstash.com

Agent 安装分布

codex 1

Skill 文档

Capabilities

Upstash provides a comprehensive serverless data platform with five core products:

  • Serverless Redis: High-performance, globally replicated Redis-compatible database with REST API access
  • Vector Database: Specialized database for semantic search and similarity matching with embedding support
  • QStash: Serverless message queue and scheduling service for reliable background jobs and event processing
  • Workflow: Durable orchestration layer for multi-step serverless functions with automatic retries and state management
  • Realtime: Low-latency messaging for real-time applications with channel-based pub/sub
  • Search: Full-text and semantic search database for building search experiences

All services scale to zero, charge per-request, support global replication, and are accessible via REST APIs from any runtime.

Skills

Redis Database

Core Operations

  • Create and manage Redis databases with multi-region replication
  • Execute all standard Redis commands (strings, hashes, lists, sets, sorted sets, streams, JSON)
  • Use REST API for HTTP-based access: GET /get/key, POST /set/key with Bearer token authentication
  • Support for pipelining multiple commands in single HTTP request
  • Atomic transactions via /multi-exec endpoint
  • Pub/Sub messaging with SUBSCRIBE, PUBLISH, and pattern matching

Data Structures

  • String operations: SET, GET, INCR, APPEND, GETRANGE
  • Hash operations: HSET, HGET, HGETALL, HINCRBY, HSCAN
  • List operations: LPUSH, RPUSH, LPOP, LRANGE, LINSERT
  • Set operations: SADD, SMEMBERS, SINTER, SUNION, SDIFF
  • Sorted Set operations: ZADD, ZRANGE, ZRANK, ZINCRBY, ZINTERSTORE
  • Stream operations: XADD, XREAD, XGROUP, XACK for event streaming
  • JSON operations: JSON.SET, JSON.GET, JSON.ARRAPPEND for structured data

Advanced Features

  • Automatic backups and point-in-time recovery
  • Key expiration with TTL management (EXPIRE, PEXPIRE, TTL)
  • Keyspace notifications for event-driven architectures
  • Lua scripting with EVAL and EVALSHA
  • Bitmap operations for efficient flag storage
  • HyperLogLog for cardinality estimation

Rate Limiting SDK

Rate Limiting Algorithms

  • Fixed window rate limiting: Allow N requests per time window
  • Sliding window rate limiting: Smooth request distribution
  • Token bucket algorithm: Flexible rate control with burst capacity
  • Custom token consumption: Different rates for different request types

Traffic Protection

  • Deny lists blocking by IP address, user agent, country, or custom identifier
  • Multi-region rate limiting across distributed Redis instances
  • Analytics dashboard tracking request patterns and blocked requests
  • Dynamic rate limit adjustment at runtime without recreating instances

Configuration

  • Per-user, per-API-key, or per-IP rate limiting
  • Different limits for free vs. paid tiers
  • Timeout handling with default allow behavior
  • Local caching to reduce Redis calls

Vector Database

Vector Operations

  • Upsert vectors with metadata: index.upsert({id, vector, metadata})
  • Similarity search: index.query({vector, topK, includeMetadata})
  • Metadata filtering with complex queries
  • Resumable queries for large result sets
  • Fetch vectors by ID: index.fetch(id)
  • Range queries: index.range(startId, endId)
  • Delete vectors: index.delete(id)
  • Update vector metadata

Index Types

  • Dense indexes for semantic/embedding search
  • Sparse indexes for keyword/full-text search
  • Hybrid indexes combining dense and sparse
  • Configurable dimensions and distance metrics (Euclidean, Cosine, DotProduct)
  • Namespace support for multi-tenancy

Features

  • Automatic embedding generation with built-in models
  • Metadata-based filtering on search results
  • Batch operations for efficient bulk indexing
  • Eventually consistent reads with configurable freshness
  • Resumable queries for handling large datasets

QStash Message Queue

Message Publishing

  • Publish messages to HTTP endpoints: client.publishJSON({url, body})
  • Guaranteed delivery with automatic retries
  • Message deduplication to prevent duplicates
  • Batch publishing for multiple messages
  • Custom headers and authentication support

Scheduling

  • Cron-based scheduling: client.schedules.create({destination, cron})
  • Timezone support with IANA timezone identifiers
  • One-time delayed delivery: client.publishJSON({url, body, delay})
  • Schedule management: create, update, delete, list schedules

Advanced Features

  • URL Groups for fan-out to multiple endpoints
  • Queues with FIFO ordering for sequential processing
  • Flow control with rate limiting (requests per second, parallelism)
  • Dead Letter Queue (DLQ) for failed messages
  • Callbacks to notify when messages are delivered
  • Batch operations for efficient bulk processing

Message Configuration

  • Custom retry policies with exponential backoff
  • Message timeout configuration
  • Request body size up to 1MB (customizable)
  • HTTP method specification (POST, PUT, PATCH)
  • Custom headers and authentication tokens

Workflow Orchestration

Workflow Definition

  • Multi-step serverless functions with automatic state management
  • Step-based execution with individual retry logic
  • Durable state preservation across function invocations
  • Built on QStash for reliability and scalability

Core Operations

  • context.run(): Execute a function step with automatic retry
  • context.sleep(): Pause workflow for specified duration
  • context.sleepUntil(): Sleep until specific timestamp
  • context.call(): Call external HTTP endpoints with retry
  • context.invoke(): Call other workflows
  • context.waitForEvent(): Wait for external events
  • context.createWebhook(): Generate webhook URLs for callbacks
  • context.notify(): Send notifications to waiting steps

Advanced Features

  • Parallel step execution with Promise.all()
  • Flow control with rate limiting and parallelism limits
  • Failure callbacks for error handling
  • Dead Letter Queue for failed workflows
  • Event-driven workflows with wait/notify patterns
  • Long-running task support beyond serverless timeouts
  • Scheduled workflows with cron expressions

Client Operations

  • client.trigger(): Start workflow execution
  • client.cancel(): Cancel running workflow
  • client.logs(): Retrieve workflow execution logs
  • client.notify(): Send events to waiting workflows
  • DLQ management: list, restart, resume, delete failed runs

Search Database

Search Operations

  • Full-text search: index.search({query, limit})
  • Semantic search with embeddings
  • Metadata-based filtering on search results
  • Reranking for improved relevance
  • Fetch documents by ID: index.fetch(id)
  • Range queries: index.range(startId, endId)
  • Delete documents: index.delete(id)
  • Batch upsert documents

Document Management

  • Upsert documents with content and metadata
  • Index-based organization for multi-tenancy
  • Content and metadata separation
  • Automatic indexing on document creation
  • Document deletion and updates

Features

  • Advanced reranking algorithms
  • Configurable search result limits
  • Metadata filtering with complex queries
  • Multiple indexes per database
  • Data browser UI for testing

Realtime Messaging

Channel Operations

  • User-specific channels: realtime.channel('user-{userId}')
  • Room-based channels: realtime.channel('room-{roomId}')
  • Team/workspace channels: realtime.channel('team-{teamId}')
  • Emit events: channel.emit('event.name', data)
  • Subscribe to channels with event filtering

Features

  • Server-side and client-side usage
  • Message history retrieval
  • Middleware support for authentication
  • Serverless-friendly architecture
  • Low-latency delivery

Workflows

Building a Rate-Limited API

  1. Create Redis database in Upstash console
  2. Initialize Ratelimit SDK with Redis connection
  3. Configure rate limiting algorithm (fixed/sliding window)
  4. In request handler, call ratelimit.limit(identifier, options)
  5. Check success flag to allow/deny request
  6. Optionally enable traffic protection with deny lists
  7. Monitor analytics dashboard for patterns

Processing Background Jobs with QStash

  1. Create public HTTP endpoint for job logic
  2. From client/server, call qstash.publishJSON({url, body})
  3. QStash delivers message to endpoint with automatic retries
  4. Endpoint processes message and returns 200 status
  5. Failed messages go to Dead Letter Queue
  6. Use DLQ to inspect and retry failed jobs
  7. Monitor logs in Upstash console

Scheduling Recurring Tasks

  1. Create QStash schedule with cron expression
  2. Specify destination URL and timezone
  3. QStash publishes message on schedule
  4. Endpoint receives and processes message
  5. Update schedule by creating with same schedule ID
  6. Delete schedule when no longer needed
  7. View schedule history in console

Building Semantic Search

  1. Create Vector index with dense type
  2. Generate embeddings for documents (via API or SDK)
  3. Upsert vectors with metadata: index.upsert({id, vector, metadata})
  4. Query with embedding: index.query({vector, topK: 10})
  5. Filter results by metadata
  6. Fetch full documents by ID
  7. Update vectors as content changes

Orchestrating Multi-Step Workflows

  1. Define workflow endpoint with serve(async (context) => {})
  2. Break logic into steps using context.run()
  3. Use context.sleep() for delays
  4. Call external APIs with context.call()
  5. Wait for events with context.waitForEvent()
  6. Handle failures with failure callbacks
  7. Trigger workflow with client.trigger()
  8. Monitor execution with client.logs()

Building Real-Time Applications

  1. Create Realtime instance with credentials
  2. Define channels for users/rooms/teams
  3. Server emits events: channel.emit('event', data)
  4. Client subscribes: useRealtime({channels, events})
  5. Client receives events in real-time
  6. Optionally retrieve message history
  7. Use middleware for authentication

Integration

Framework Support

  • Next.js (App Router and Pages Router)
  • Vercel Functions and Vercel deployments
  • Cloudflare Workers and Durable Objects
  • AWS Lambda and AWS SAM
  • Google Cloud Functions
  • Azure Functions
  • Deno Deploy
  • Fly.io
  • FastAPI, Flask, Django (Python)
  • Express.js, Hono, Astro
  • Laravel, Supabase

SDK Languages

  • TypeScript/JavaScript: @upstash/redis, @upstash/qstash, @upstash/vector, @upstash/workflow
  • Python: upstash-redis, upstash-qstash, upstash-vector
  • Go: Official Go SDKs
  • PHP: Official PHP SDKs

Third-Party Integrations

  • LangChain for AI/ML workflows
  • LlamaIndex for document indexing
  • OpenAI and Anthropic for LLM integration
  • Datadog and Prometheus for monitoring
  • Resend for email delivery
  • n8n and Pipedream for automation
  • BullMQ for job queues
  • Sidekiq for Ruby background jobs
  • Celery for Python task queues
  • Drizzle ORM for database operations
  • MCP (Model Context Protocol) for AI tools

Developer Tools

  • Terraform provider for infrastructure as code
  • Pulumi for programmatic infrastructure
  • CLI for local development
  • Developer API for account management
  • REST API for all services

Context

Serverless Architecture

  • Per-request pricing model: Pay only for what you use
  • Scale to zero: No charges when idle
  • No connection management required
  • Ideal for AWS Lambda, Vercel, Cloudflare Workers
  • HTTP-based access from any runtime

Global Replication

  • Multi-region data replication for low latency
  • Read replicas in different regions
  • Automatic failover for high availability
  • 99.99% uptime SLA (Prod Pack)

Data Consistency

  • Redis: Strong consistency with optional replication
  • Vector: Eventually consistent with configurable freshness
  • Transactions support for atomic operations
  • Pub/Sub for event-driven architectures

Security

  • Bearer token authentication
  • Read-only tokens for public access
  • ACL support for fine-grained permissions
  • TLS encryption in transit
  • Optional encryption at rest
  • SOC-2 compliance available

Performance Characteristics

  • Ultra-low latency worldwide
  • Automatic scaling without configuration
  • Pipelining support for batch operations
  • Connection pooling handled automatically
  • REST API eliminates TCP connection overhead

Limitations and Considerations

  • Redis: Supports protocol up to version 8.2
  • Blocking commands (BLPOP, BRPOP) not supported in REST API
  • Vector: Eventually consistent reads
  • QStash: 1MB message size limit (customizable)
  • Workflow: Built on QStash, inherits its limitations
  • Realtime: Serverless-optimized, not for persistent connections

For additional documentation and navigation, see: https://upstash.com/docs/llms.txt