Setu-TS
    Preparing search index...

    Class RedisRateLimitStore

    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.

    Implements

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

      Parameters

      • options: {
            client?: IRateLimitRedisClient;
            commandTimeoutMs?: number;
            connectionErrorReporter?: ConnectionErrorReporter;
            keyPrefix?: string;
            runtime: IRuntimeServices;
            url?: string;
        }

        Connection, injected client, runtime clock, key namespace

        • Optionalclient?: IRateLimitRedisClient
        • OptionalcommandTimeoutMs?: number

          Bound on a built client's command, in ms; defaults to 15000. 0 omits the bound. Ignored for an injected client.

          0.10.0

        • OptionalconnectionErrorReporter?: ConnectionErrorReporter

          Receives the connection errors (ioredis 'error' events) of the client this store BUILDS, instead of ioredis printing each reconnect failure to the console. Never attached to an injected client, which belongs to the caller. This store is constructed by the application, so no plugin supplies one: build it with createConnectionErrorReporter from @setu-ts/common over your logger. Absent, the built client's connection errors are dropped: nothing reaches the console or a log.

          0.8.0

        • OptionalkeyPrefix?: string

          Namespace prepended to every key this store reads and writes. Defaults to DEFAULT_RATE_LIMIT_KEY_PREFIX.

          keyGenerator produces keys such as anonymous and ip:203.0.113.7, which are generic enough that two applications sharing one managed Redis would count against each other's budget — service A's traffic exhausting service B's limit. Pass a per-application value when one Redis serves several.

          0.5.0

        • runtime: IRuntimeServices
        • Optionalurl?: string

      Returns RedisRateLimitStore