# IRateLimiter

`interface` in `types` · v0.8.0-next.6

<https://docs.seedcord.org/packages/types/0.8.0-next.6/interfaces/irate-limiter>

Sliding-window rate limiting keyed by caller-built strings, available as `core.rateLimiter`.

Async so one interface spans the in-memory default and durable store backends. The in-memory implementation resolves synchronously, so the `await` costs no event-loop yield.

```ts
interface IRateLimiter
```

## Methods

### charge

```ts
async charge(
    key: string,
    window: RateLimitWindow
): Promise<RateLimitResult>
```

Records a use of `key` if the window has a free slot, in one atomic step.

### peek

```ts
async peek(
    key: string,
    window: RateLimitWindow
): Promise<RateLimitResult>
```

Reports `key`'s limited state without recording a use.

The read half of a peek-then-commit. The `Cooldown` gate peeks in its check and charges in its commit, so a refusal elsewhere in the gate set never burns the slot.

### reset

```ts
async reset(key: string): Promise<void>
```

Clears `key`'s recorded uses.
