/** * @module @arcis/node/stores/redis * Redis rate limit store * * Note: This is a reference implementation. You'll need to install * the 'ioredis' or 'redis' package and pass your client instance. */ import type { RateLimitStore, RateLimitEntry } from '../core/types'; /** Generic Redis client interface (works with ioredis, redis, etc.) */ export interface RedisClientLike { get(key: string): Promise; /** * SET with optional flags. Supports both `set(key, value)` and * `set(key, value, 'EX', seconds, 'NX')` shapes for atomic * set-if-not-exists with TTL. Returns 'OK' on success; null when NX * is supplied and the key already exists. */ set(key: string, value: string, ...args: Array): Promise; setex(key: string, seconds: number, value: string): Promise; expire(key: string, seconds: number): Promise; incr(key: string): Promise; decr(key: string): Promise; del(key: string): Promise; ttl(key: string): Promise; quit?(): Promise; disconnect?(): Promise; } export interface RedisStoreOptions { /** Redis client instance */ client: RedisClientLike; /** Key prefix. Default: 'arcis:rl:' */ prefix?: string; /** Window size in milliseconds. Default: 60000 */ windowMs?: number; } /** * Redis rate limit store for distributed deployments. * * @example * import Redis from 'ioredis'; * * const redis = new Redis(); * const store = new RedisStore({ client: redis }); * const limiter = createRateLimiter({ store }); * * // Cleanup on shutdown * process.on('SIGTERM', async () => { * await store.close(); * }); */ export declare class RedisStore implements RateLimitStore { private client; private prefix; private windowMs; private windowSec; constructor(options: RedisStoreOptions); private getKey; get(key: string): Promise; set(key: string, entry: RateLimitEntry): Promise; increment(key: string): Promise; decrement(key: string): Promise; reset(key: string): Promise; close(): Promise; } /** * Create a Redis store with the given options. * Convenience function for functional programming style. * * @example * const store = createRedisStore({ client: redisClient }); */ export declare function createRedisStore(options: RedisStoreOptions): RedisStore; //# sourceMappingURL=redis.d.ts.map