strict-rate-limiter
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -123,7 +123,7 @@ // imports | ||
if (res === null || res[2] === 0) { | ||
if (res === null || res[2][1] === 0) { | ||
// res[2] === 0 means already locked, try again later | ||
return retry.bind(this)(); | ||
} else if (res[1] < 0) { | ||
} else if (res[1][1] < 0) { | ||
// TTL is 0, start new limiter | ||
@@ -135,5 +135,5 @@ this.start(); | ||
// all good, set .remaining and .reset | ||
this.remaining = (res[0] >> 0) - 1; | ||
this.remaining = (res[0][1] >> 0) - 1; | ||
this.reset = new Date(); | ||
this.reset.setMilliseconds(this.reset.getMilliseconds() + (res[1] >> 0)); | ||
this.reset.setMilliseconds(this.reset.getMilliseconds() + (res[1][1] >> 0)); | ||
} | ||
@@ -140,0 +140,0 @@ |
{ | ||
"name": "strict-rate-limiter", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Rate limiter backed by redis with strict concurrency rules for scalable applications", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"jshint": "^2.5.10", | ||
"redis": "^0.12.1" | ||
"ioredis": "^1.15.1" | ||
}, | ||
@@ -23,4 +23,4 @@ "dependencies": { | ||
"type": "git", | ||
"url": "git://github.com/getc/strict-rate-limiter.git" | ||
"url": "git://github.com/ovx/strict-rate-limiter.git" | ||
} | ||
} |
var assert = require('assert'), | ||
RateLimiter = require('../index'), | ||
redis = require('redis'); | ||
Redis = require('ioredis'); | ||
@@ -9,3 +9,3 @@ var ID = 'testlimiter', | ||
var redisClient = redis.createClient(); | ||
var redisClient = new Redis(); | ||
@@ -148,2 +148,2 @@ describe('Setup', function () { | ||
}); | ||
}); | ||
}); |
11614
268