import { OnModuleDestroy } from '@nestjs/common'; import { IRateLimitPluginOptions, IRateLimitResult } from '../../../shared/types'; import { IRateLimitStore } from '../../application/ports/rate-limit-store.port'; /** * In-memory (per-instance) rate limit store. * * Counters live in process memory: no Redis round-trip on the request path, * at the cost of per-node (approximate) limits. Node's single-threaded event * loop makes each check atomic without locking. * * Memory safety: Redis bounds its keyspace via EXPIRE; here a key cap with * oldest-first eviction plus a periodic sweep of expired entries prevents * unbounded growth under key spray (e.g. random IPs). The sweep timer starts * lazily on first use and never keeps the process alive (unref). */ export declare class InMemoryRateLimitStoreAdapter implements IRateLimitStore, OnModuleDestroy { private readonly entries; private readonly maxKeys; private readonly sweepIntervalMs; private sweepTimer; constructor(options?: IRateLimitPluginOptions); /** Number of tracked keys (monitoring/testing aid). */ get size(): number; fixedWindow(key: string, points: number, duration: number): Promise; slidingWindow(key: string, points: number, duration: number): Promise; tokenBucket(key: string, capacity: number, refillRate: number, consume?: number): Promise; peek(key: string, algorithm: string, config: Record): Promise; reset(key: string): Promise; onModuleDestroy(): void; private write; /** * Approximate FIFO eviction: Map preserves insertion order, so the first * key is the oldest-inserted one. Limiter entries are short-lived, which * makes insertion age a good enough proxy for staleness. */ private evictOldest; private ensureSweepTimer; private sweep; } //# sourceMappingURL=in-memory-rate-limit-store.adapter.d.ts.map