@pwngh/economy-lab
    Preparing search index...

    Function redisRateLimiter

    • Adapts an already-connected ioredis client into a fixed-window RateLimiter: INCR on the windowed key, PEXPIRE arms the window on its first hit, and a denial reports the key's remaining PTTL. The caller creates and owns the client, same as redisCache; the returned close() releases the connection.

      Each key gets limit calls per windowMs; because the counter lives in Redis, the limit holds across every process sharing the instance. A denial whose key has lost its TTL reports a full windowMs wait rather than a negative one. Keys live under the economy:ratelimit: prefix, and a failed call throws a retryable STORE.FAILURE rather than silently allowing.

      Parameters

      • client: RedisCounterClient
      • options: { limit: number; windowMs: number }

      Returns RateLimiter & { close(): Promise<void> }

      HTTP service for how the server keys and answers denials.