FallbackRateLimitStorage
FallbackRateLimitStorage
Storage wrapper that falls back to a secondary implementation on failure.
class FallbackRateLimitStorage implements RateLimitStorage {
constructor(primary: RateLimitStorage, secondary: RateLimitStorage, options: FallbackRateLimitStorageOptions = {})
get(key: string) => Promise<T | null>;
set(key: string, value: T, ttlMs?: number) => Promise<void>;
delete(key: string) => Promise<void>;
incr(key: string, ttlMs: number) => ;
ttl(key: string) => ;
expire(key: string, ttlMs: number) => ;
zAdd(key: string, score: number, member: string) => ;
zRemRangeByScore(key: string, min: number, max: number) => ;
zCard(key: string) => ;
zRangeByScore(key: string, min: number, max: number) => ;
consumeFixedWindow(key: string, limit: number, windowMs: number, nowMs: number) => ;
consumeSlidingWindowLog(key: string, limit: number, windowMs: number, nowMs: number, member: string) => ;
deleteByPrefix(prefix: string) => ;
deleteByPattern(pattern: string) => ;
keysByPrefix(prefix: string) => ;
}
- Implements:
RateLimitStorage
constructor
(primary: RateLimitStorage, secondary: RateLimitStorage, options: FallbackRateLimitStorageOptions = {}) => FallbackRateLimitStorageCreate a fallback wrapper with primary/secondary storages.
get
(key: string) => Promise<T | null>Read a value using primary storage with fallback.
set
(key: string, value: T, ttlMs?: number) => Promise<void>Store a value using primary storage with fallback.
delete
(key: string) => Promise<void>Delete a key using primary storage with fallback.
incr
(key: string, ttlMs: number) => Increment a fixed-window counter using primary storage with fallback.
ttl
(key: string) => Read TTL using primary storage with fallback.
expire
(key: string, ttlMs: number) => Update TTL using primary storage with fallback.
zAdd
(key: string, score: number, member: string) => Add a member to a sorted set using primary storage with fallback.
zRemRangeByScore
(key: string, min: number, max: number) => Remove sorted-set members in a score range with fallback.
zCard
(key: string) => Count sorted-set members with fallback.
zRangeByScore
(key: string, min: number, max: number) => Read sorted-set members in a score range with fallback.
consumeFixedWindow
(key: string, limit: number, windowMs: number, nowMs: number) => Atomically consume a fixed-window counter with fallback.
consumeSlidingWindowLog
(key: string, limit: number, windowMs: number, nowMs: number, member: string) => Atomically consume a sliding-window log with fallback.
deleteByPrefix
(prefix: string) => Delete keys with a prefix using primary storage with fallback.
deleteByPattern
(pattern: string) => Delete keys matching a pattern using primary storage with fallback.
keysByPrefix
(prefix: string) => List keys matching a prefix using primary storage with fallback.