SlidingWindowLogAlgorithm
SlidingWindowLogAlgorithm
Sliding-window log algorithm for smoother limits.
Signature
class SlidingWindowLogAlgorithm implements RateLimitAlgorithm {
public readonly type: RateLimitAlgorithmType = 'sliding-window';
constructor(storage: RateLimitStorage, config: SlidingWindowConfig)
consume(key: string) => Promise<RateLimitResult>;
reset(key: string) => Promise<void>;
}
- Implements:
RateLimitAlgorithm
type
property
constructor
method
(storage: RateLimitStorage, config: SlidingWindowConfig) => SlidingWindowLogAlgorithmCreate a sliding-window algorithm bound to a storage backend.
consume
method
(key: string) => Promise<RateLimitResult>Record one attempt and return the current window status for this key.
reset
method
(key: string) => Promise<void>Reset the stored key state for this limiter.