[]previous and next page

RateLimitStore

Where bucket state lives.

Where bucket state lives. The in-memory store is for one process; implement this interface on a shared store (Redis, a database) for several. take must be atomic.

Import#

ts
import type { RateLimitStore } from "@shadow-js/dusk/server";

Signature#

ts
interface RateLimitStore {
  take(
    key: string,
    spec: BucketSpec,
    cost: number,
    now: number,
  ): RateLimitDecision | Promise<RateLimitDecision>;
}

Members#

Name Type Description
take take( key: string, spec: BucketSpec, cost: number, now: number, ): RateLimitDecision | Promise<RateLimitDecision>