RedisRateLimitStore
Defined in: packages/rest/src/redis.ts:287
Redis-backed implementation of RateLimitStore for distributed rate limit synchronization: workers sharing one Redis share every limit, reserve allowance atomically, and merge responses atomically.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RedisRateLimitStore(
options):RedisRateLimitStore
Defined in: packages/rest/src/redis.ts:308
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”RedisRateLimitStore
Properties
Section titled “Properties”extendGlobalReset?
Section titled “extendGlobalReset?”
optionalextendGlobalReset?: (scope,waitMs) =>Promise<void>
Defined in: packages/rest/src/redis.ts:581
Atomically extends a global limit, never shortening it.
Parameters
Section titled “Parameters”string
waitMs
Section titled “waitMs”number
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”RateLimitStore.extendGlobalReset
reconcile?
Section titled “reconcile?”
optionalreconcile?: (key,update) =>Promise<void>
Defined in: packages/rest/src/redis.ts:579
Atomically merges a response into the bucket.
Parameters
Section titled “Parameters”string
update
Section titled “update”Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”release?
Section titled “release?”
optionalrelease?: (key,grant,refund) =>Promise<void>
Defined in: packages/rest/src/redis.ts:583
Clears a probe placeholder or refunds an unsent request’s unit.
Parameters
Section titled “Parameters”string
resetAt?
Section titled “resetAt?”number
refund
Section titled “refund”boolean
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”reserve?
Section titled “reserve?”
optionalreserve?: (key,options?) =>Promise<Reservation>
Defined in: packages/rest/src/redis.ts:574
Atomically checks the global limit and consumes one unit of the bucket.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<Reservation>
Implementation of
Section titled “Implementation of”reservesGlobal?
Section titled “reservesGlobal?”
readonlyoptionalreservesGlobal?:boolean
Defined in: packages/rest/src/redis.ts:589
Whether reserve checks the global limit itself.
Implementation of
Section titled “Implementation of”Accessors
Section titled “Accessors”lastError
Section titled “lastError”Get Signature
Section titled “Get Signature”get lastError():
unknown
Defined in: packages/rest/src/redis.ts:343
The most recent Redis error, if any.
Returns
Section titled “Returns”unknown
Get Signature
Section titled “Get Signature”get mode():
CoordinationMode
Defined in: packages/rest/src/redis.ts:353
How limits are being enforced right now.
Returns
Section titled “Returns”supportsReservation
Section titled “supportsReservation”Get Signature
Section titled “Get Signature”get supportsReservation():
boolean
Defined in: packages/rest/src/redis.ts:358
Whether the backing client supports atomic reservations.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”diagnostics()
Section titled “diagnostics()”diagnostics():
RedisStoreDiagnostics
Defined in: packages/rest/src/redis.ts:363
The store’s current health.
Returns
Section titled “Returns”getBucket()
Section titled “getBucket()”getBucket(
key):Promise<BucketState|undefined>
Defined in: packages/rest/src/redis.ts:534
Gets the current state for a bucket key.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<BucketState | undefined>
Implementation of
Section titled “Implementation of”getBucketHash()
Section titled “getBucketHash()”getBucketHash(
route):Promise<string|undefined>
Defined in: packages/rest/src/redis.ts:506
Gets the server bucket hash for a normalized route.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<string | undefined>
Implementation of
Section titled “Implementation of”getGlobalReset()
Section titled “getGlobalReset()”getGlobalReset(
scope?):Promise<number>
Defined in: packages/rest/src/redis.ts:694
Gets the global reset timestamp (of scope, when the store keeps several).
Parameters
Section titled “Parameters”scope?
Section titled “scope?”string = ""
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”isHealthy()
Section titled “isHealthy()”isHealthy():
boolean
Defined in: packages/rest/src/redis.ts:348
Whether no Redis operation has failed since construction or the last successful one.
Returns
Section titled “Returns”boolean
setBucketHash()
Section titled “setBucketHash()”setBucketHash(
route,hash):Promise<void>
Defined in: packages/rest/src/redis.ts:517
Associates a route with a server bucket hash.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”setGlobalReset()
Section titled “setGlobalReset()”setGlobalReset(
resetAt,scope?):Promise<void>
Defined in: packages/rest/src/redis.ts:706
Sets the global reset timestamp (of scope, when the store keeps several).
Parameters
Section titled “Parameters”resetAt
Section titled “resetAt”number
scope?
Section titled “scope?”string = ""
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”updateBucket()
Section titled “updateBucket()”updateBucket(
key,state):Promise<void>
Defined in: packages/rest/src/redis.ts:551
Replaces the state for a bucket key.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”verify()
Section titled “verify()”verify():
Promise<void>
Defined in: packages/rest/src/redis.ts:387
Checks that the client can run the store’s scripts (some managed Redis
services disable EVAL). Call it at startup to fail fast.
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the client has no eval.
Throws
Section titled “Throws”Of kind "coordination", if the script cannot run.