A rolling token bucket rate limiter implemented via a Lua script in Redis for atomic operations. v0.5.1 is the latest stable version. It supports ioredis (including Redis Cluster) and node-redis clients. Key differentiator: uses a Lua script to prevent blocked actions from subtracting from the bucket and ensures consistency, even with concurrent requests. Ideal for Node.js applications needing precise rate limiting with Redis.
npm install redis-token-bucket-ratelimiterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a RollingLimit with a 60-second interval, 10 maximum uses, then checks rate limit for a user ID, logging remaining tokens and retry time.
Ensure interval > 0 and limit >= 0.
Call `await redis.connect()` before creating the limiter.
Use `prefix: 'myapp:'` instead of `prefix: 'myapp'`.
Avoid using `force`; instead design logic to handle rejection.
Refer to source code to confirm behavior with amount=0.
Use `const RollingLimit = require('redis-token-bucket-ratelimiter')`.Add `await redis.connect()` or ensure connection is established.
Verify correct import: `const RollingLimit = require('redis-token-bucket-ratelimiter')` and then `const limiter = new RollingLimit(...)`.