FixedWindowAlgorithm
FixedWindowAlgorithm
Basic fixed-window counter for low-cost rate limits.
Signature
class FixedWindowAlgorithm implements RateLimitAlgorithm {
public readonly type: RateLimitAlgorithmType = 'fixed-window';
constructor(storage: RateLimitStorage, config: FixedWindowConfig)
consume(key: string) => Promise<RateLimitResult>;
reset(key: string) => Promise<void>;
}
- Implements:
RateLimitAlgorithm
type
property
constructor
method
(storage: RateLimitStorage, config: FixedWindowConfig) => FixedWindowAlgorithmCreate a fixed-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.