Skip to content

basalt / auth/src / MemoryThrottleStore

Class: MemoryThrottleStore ​

Defined in: auth/src/throttle.ts:77

In-process ThrottleStore (the default): synchronous and bounded.

Implements ​

Constructors ​

Constructor ​

> new MemoryThrottleStore(options?): MemoryThrottleStore

Defined in: auth/src/throttle.ts:82

Parameters ​

options? ​

MemoryThrottleStoreOptions = {}

Returns ​

MemoryThrottleStore

Accessors ​

size ​

Get Signature ​

> get size(): number

Defined in: auth/src/throttle.ts:88

Number of keys currently tracked.

Returns ​

number

Methods ​

hit() ​

> hit(key, windowMs, limit?): ThrottleWindow

Defined in: auth/src/throttle.ts:127

Atomically counts one attempt and returns the new state. The first hit of a key opens a fixed window of windowMs; later hits do not extend it.

limit is the caller's budget: once count >= limit the key is locked. A bounded store uses it to keep locked keys over unlocked ones when it has to evict; stores without eviction may ignore it.

Parameters ​

key ​

string

windowMs ​

number

limit? ​

number

Returns ​

ThrottleWindow

Implementation of ​

ThrottleStore.hit


peek() ​

> peek(key): ThrottleWindow | null

Defined in: auth/src/throttle.ts:136

The current state without counting; null when the key has no live window.

Parameters ​

key ​

string

Returns ​

ThrottleWindow | null

Implementation of ​

ThrottleStore.peek


release() ​

> release(key): void

Defined in: auth/src/throttle.ts:142

Gives one attempt back (a successful attempt must not consume budget).

Parameters ​

key ​

string

Returns ​

void

Implementation of ​

ThrottleStore.release


reset() ​

> reset(key): void

Defined in: auth/src/throttle.ts:149

Forgets the key.

Parameters ​

key ​

string

Returns ​

void

Implementation of ​

ThrottleStore.reset


retainedKeyChars() ​

> retainedKeyChars(): number

Defined in: auth/src/throttle.ts:93

Total characters retained in keys — diagnostics for memory bounds.

Returns ​

number

Released under the MIT License.