MemoryRateLimitStore
Defined in: packages/rest/src/store.ts:304
Local memory implementation of RateLimitStore.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MemoryRateLimitStore():
MemoryRateLimitStore
Defined in: packages/rest/src/store.ts:317
Creates an empty instance.
Returns
Section titled “Returns”MemoryRateLimitStore
Properties
Section titled “Properties”reservesGlobal
Section titled “reservesGlobal”
readonlyreservesGlobal:true=true
Defined in: packages/rest/src/store.ts:314
Whether reserve also checks options.global atomically. When
it does not, the limiter reads the global reset itself first.
Implementation of
Section titled “Implementation of”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get size():
number
Defined in: packages/rest/src/store.ts:439
Number of buckets held (for diagnostics and leak checks).
Returns
Section titled “Returns”number
Methods
Section titled “Methods”extendGlobalReset()
Section titled “extendGlobalReset()”extendGlobalReset(
scope,waitMs):void
Defined in: packages/rest/src/store.ts:433
Atomically extends a global limit to at least waitMs from now, never
shortening a longer one. Optional: without it the limiter reads and
writes, which a concurrent writer can shorten.
Parameters
Section titled “Parameters”string
waitMs
Section titled “waitMs”number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”RateLimitStore.extendGlobalReset
getBucket()
Section titled “getBucket()”getBucket(
key):BucketState|undefined
Defined in: packages/rest/src/store.ts:332
Gets the current state for a bucket key.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”BucketState | undefined
Implementation of
Section titled “Implementation of”getBucketHash()
Section titled “getBucketHash()”getBucketHash(
route):string|undefined
Defined in: packages/rest/src/store.ts:324
Gets the server bucket hash for a normalized route.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string | undefined
Implementation of
Section titled “Implementation of”getGlobalReset()
Section titled “getGlobalReset()”getGlobalReset(
scope?):number
Defined in: packages/rest/src/store.ts:426
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”number
Implementation of
Section titled “Implementation of”prune()
Section titled “prune()”prune(
maxAge?):void
Defined in: packages/rest/src/store.ts:415
Removes buckets whose reset is in the past (or older than maxAge ms).
Parameters
Section titled “Parameters”maxAge?
Section titled “maxAge?”number = 0
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”reconcile()
Section titled “reconcile()”reconcile(
key,update):void
Defined in: packages/rest/src/store.ts:378
Atomically merges what a response said into a bucket, so a late or out-of-order response cannot hand back allowance already reserved. Optional: without it the limiter reads, merges and writes.
Parameters
Section titled “Parameters”string
update
Section titled “update”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”release()
Section titled “release()”release(
key,grant,refund):void
Defined in: packages/rest/src/store.ts:383
Gives back what a granted reservation held, when that is certain to be
safe: a probe placeholder is cleared (so the next request may probe),
and with refund — the request was never sent — the unit is returned
to the window it came from, if that window is still current.
Parameters
Section titled “Parameters”string
resetAt?
Section titled “resetAt?”number
refund
Section titled “refund”boolean
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”reserve()
Section titled “reserve()”reserve(
key,options?):Reservation
Defined in: packages/rest/src/store.ts:341
Consumes one unit of the bucket’s allowance.
Single-process reservation is trivially atomic: JavaScript will not interleave this method with another caller’s copy of it.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”ReserveOptions = {}
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”setBucketHash()
Section titled “setBucketHash()”setBucketHash(
route,hash):void
Defined in: packages/rest/src/store.ts:327
Associates a route with a server bucket hash.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setGlobalReset()
Section titled “setGlobalReset()”setGlobalReset(
resetAt,scope?):void
Defined in: packages/rest/src/store.ts:429
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”void
Implementation of
Section titled “Implementation of”updateBucket()
Section titled “updateBucket()”updateBucket(
key,state):void
Defined in: packages/rest/src/store.ts:397
Replaces the state for a bucket key.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void