createKvRateLimitStore
Token buckets over a KV store.
Token buckets over a KV store. A take reads the bucket, decides with the same arithmetic as the memory store, and writes it back under a per-key lock (so concurrent takes in one process cannot overdraw). The entry expires when the bucket would be full again, because a full bucket is the same as no bucket.
Import#
ts
import { createKvRateLimitStore } from "@shadow-js/dusk/server";
Signature#
ts
function createKvRateLimitStore(
kv: KVStore,
options: { readonly prefix?: string } = {},
): RateLimitStore
Parameters#
| Name | Description |
|---|---|
kv |
The store. |
options |
The prefix. |
Returns#
A RateLimitStore.