Class: RedisRateLimitStore
Defined in: rate-limit.ts:124 IRateLimitStore backed by Upstash Redis using the@upstash/ratelimit sliding-window algorithm.
Internally caches one Ratelimit instance per (windowMs, maxRequests) pair so re-using the same store across multiple routes
does not allocate a new limiter every call.
Use this for any deployment that runs more than one process — counters
are shared across all nodes via Redis.
Example
Implements
Constructors
Constructor
new RedisRateLimitStore(Defined in: rate-limit.ts:132redisClient):RedisRateLimitStore
Parameters
redisClient
Redis
Connected Upstash Redis client. Reuse the same
client across stores; do not allocate per request.
Returns
RedisRateLimitStore
Methods
check()
check(Defined in: rate-limit.ts:151 Atomically increment the counter forkey,windowMs,maxRequests):Promise<{limited:boolean;remaining:number;resetTime:number;total:number; }>
key within a sliding window
of windowMs and decide whether to allow the request.
Parameters
key
string
Caller-chosen identity key (e.g. "user:42").
windowMs
number
Window length in milliseconds.
maxRequests
number
Maximum requests permitted in the window.
Returns
Promise<{ limited: boolean; remaining: number; resetTime: number; total: number; }>
A RateLimitCheckResult describing the decision.
Implementation of
IRateLimitStore.check
reset()
reset(Defined in: rate-limit.ts:172_key):Promise<void>
Parameters
_key
string
Returns
Promise<void>
Inherit Doc
a no-op.**@upstash/ratelimit distributes counters
across multiple sliding-window keys per limiter, and there is no
single delete that resets all of them. Provided for interface
conformance; future versions may scan the prefix and clear all
matching keys.
Implementation of
IRateLimitStore.reset