/** * Upstash Redis Storage Adapter * * Upstash Redis (REST-based) storage implementation for edge deployment. * Supports pub/sub via Upstash's REST API with polling mechanism. */ import { BaseStorageAdapter } from './base'; import type { UpstashAdapterOptions, SetOptions, MessageHandler, Unsubscribe } from '../types'; /** * Upstash Redis storage adapter. * * Features: * - REST-based storage for edge deployment * - Native TTL support * - Pub/sub support via list-based polling * * @example * ```typescript * const adapter = new UpstashStorageAdapter({ * url: process.env.UPSTASH_REDIS_REST_URL, * token: process.env.UPSTASH_REDIS_REST_TOKEN, * enablePubSub: true, * }); * * await adapter.connect(); * await adapter.set('key', 'value', { ttlSeconds: 300 }); * const value = await adapter.get('key'); * * // Pub/sub * const unsubscribe = await adapter.subscribe('channel', (msg) => console.log(msg)); * await adapter.publish('channel', 'hello'); * * await adapter.disconnect(); * ``` */ export declare class UpstashStorageAdapter extends BaseStorageAdapter { protected readonly backendName = "upstash"; private client?; private readonly options; private readonly keyPrefix; private readonly pubSubEnabled; private readonly subscriptionHandlers; private readonly pollingIntervals; constructor(options?: UpstashAdapterOptions); connect(): Promise; disconnect(): Promise; ping(): Promise; /** * Get the connected Upstash client, throwing if not connected. */ private getConnectedClient; get(key: string): Promise; protected doSet(key: string, value: string, options?: SetOptions): Promise; delete(key: string): Promise; exists(key: string): Promise; mget(keys: string[]): Promise<(string | null)[]>; mdelete(keys: string[]): Promise; expire(key: string, ttlSeconds: number): Promise; ttl(key: string): Promise; keys(pattern?: string): Promise; incr(key: string): Promise; decr(key: string): Promise; incrBy(key: string, amount: number): Promise; supportsPubSub(): boolean; publish(channel: string, message: string): Promise; subscribe(channel: string, handler: MessageHandler): Promise; /** * Publish using list-based approach (for polling subscribers). * This is an alternative to native PUBLISH when subscribers are polling. */ publishToQueue(channel: string, message: string): Promise; protected getPubSubSuggestion(): string; /** * Add prefix to a key. */ private prefixKey; /** * Remove prefix from a key. */ private unprefixKey; }