class RedisRateLimitStore
implements RateLimitStore

Redis-backed rate limit store implementation.

Uses INCR (creates if missing) + PEXPIRE on first increment, then PTTL to derive resetTime. The store holds the runtime clock because PTTL returns a relative ms-remaining value, while the contract's RateLimitResult.resetTime must be an absolute epoch-ms timestamp.

Constructors

RedisRateLimitStore(options: { url?: string | undefined; client?: IRateLimitRedisClient | undefined; runtime: IRuntimeServices; keyPrefix?: string | undefined; })

Builds the store. The client is resolved lazily on first use, so constructing this costs no connection.

Parameters
options: { url?: string | undefined; client?: IRateLimitRedisClient | undefined; runtime: IRuntimeServices; keyPrefix?: string | undefined; }

Connection, injected client, runtime clock, key namespace

Methods

disconnect(): Promise<void>

Close the Redis connection (calls QUIT).

increment(
key: string,
windowMs: number
): Promise<RateLimitResult>

Increment the counter for the given key within its window. Creates the window if it does not exist.

reset(key: string): Promise<void>

Reset the counter for the given key.

Usage

import { RedisRateLimitStore } from "auth-plugin/src/index.ts";