Rate-limit any operation with Redis, using a fixed-window algorithm. Current stable version is 1.2.0. The package is lightweight and focuses on performance (>10,000 checks/sec on local Redis) and race-condition safety. It provides a simple API for creating rate limiters with shorthands like '100/minute' and includes built-in HTTP middleware for Express/Restify. Unlike rolling-window implementations like ratelimiter, this uses fixed windows which can allow traffic bursts at window edges. The package has low maintenance activity and limited documentation, but works reliably for basic use cases.
npm install redis-rate-limiterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Redis client and a rate limiter with a limit of 100 requests per minute based on IP. Simulates periodic requests and logs the result.
Use a sliding window algorithm if bursts at boundaries are unacceptable.
If using a custom function, ensure it receives the same object passed to limit(). For 'ip', the object must have a 'connection' or 'socket' property with 'remoteAddress'.
Consider alternatives like express-rate-limit (with Redis store) or rate-limiter-flexible.
Start Redis server: redis-server, or check the connection options passed to redis.createClient().
Use require('redis-rate-limiter') instead of import. The package is CommonJS only.