rate-limiter-flexible
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -23,6 +23,4 @@ class RateLimiter { | ||
const rlKey = RateLimiter.getKey(key); | ||
const tempKey = `tmp${rlKey}`; | ||
this.redis.multi() | ||
.setex(tempKey, this.duration, 0) | ||
.renamenx(tempKey, rlKey) | ||
.set(rlKey, 0, 'EX', this.duration, 'NX') | ||
.incrby(rlKey, rate) | ||
@@ -36,3 +34,3 @@ .pttl(rlKey) | ||
} else { | ||
const [,, consumed, resTtlMs] = results; | ||
const [, consumed, resTtlMs] = results; | ||
if (resTtlMs === -1) { | ||
@@ -39,0 +37,0 @@ msBeforeReset = this.duration; |
{ | ||
"name": "rate-limiter-flexible", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Flexible API rate limiter backed by Redis for distributed node.js applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
4590
56