A Redis-backed leaky-bucket rate limiter (v2.0.0) that uses EVAL/EVALSHA-based Lua scripts for atomic operations, enabling shared rate-limiting across distributed instances without Redis modules. Supports tiered capacity and rate metrics with configurable backoff. Actively maintained with TypeScript types included. Compared to alternatives like express-rate-limit (in-memory), it provides centralized state; compared to ratelimiter (Redis-based with custom modules), it works on hosted Redis without module support.
npm install redis-bucketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Redis client, connects, and initializes a rate limiter with capacity-based limits and exponential backoff.
Update callback signature to accept unknown[] and convert as needed.
Provide evalsha callback to leverage script caching.
Migrate to v2 callback interface as shown in the API docs.
Adjust logic that expects integer free values.
Use a Redis client with built-in reconnection (e.g., ioredis) or implement your own retry/handle in the eval callback.
Update configuration to use the object format.
If upgrading, consider using exponential backoff or specify your own backoff function.
Use a standard Redis client like 'redis' or 'ioredis' that implements eval. Ensure you are passing the correct client reference.
Configure your Redis client to automatically reconnect (e.g., enable retry strategy in ioredis or use a resilient client).
Use import { create } from 'redis-bucket' and then call create(config) to get the limit function.Ensure eval/evalsha callbacks return the result from Redis client's eval/evalsha directly (array of values). Do not modify.
Update to redis-bucket@2.0.0 with npm install redis-bucket@latest. If locking, ensure @types are up to date.