Skip to content

Commit

Permalink
Remove tidy option. fix #51
Browse files Browse the repository at this point in the history
  • Loading branch information
noamshemesh committed Aug 16, 2019
1 parent d8e1e50 commit b958870
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 290 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dump.rdb
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Rate limiter for Node.js backed by Redis.
[![Build Status](https://travis-ci.org/tj/node-ratelimiter.svg)](https://travis-ci.org/tj/node-ratelimiter)

## Release Notes
[v3.3.1](https://github.com/tj/node-ratelimiter/tree/v3.3.1) - [#51](/../../issues/47) - Remove tidy option as it's always true.

[v3.3.0](https://github.com/tj/node-ratelimiter/tree/v3.3.0) - [#47](/../../pull/47) by [@penghap](https://github.com/penghap) - Add tidy option to clean old records upon saving new records. Drop support in node 4.

[v3.2.0](https://github.com/tj/node-ratelimiter/tree/v3.2.0) - [#44](/../../pull/44) by [@xdmnl](https://github.com/xdmnl) - Return accurate reset time for each limited call.
Expand Down
7 changes: 2 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = Limiter;
function Limiter(opts) {
this.id = opts.id;
this.db = opts.db;
this.tidy = opts.tidy || false;
assert(this.id, '.id required');
assert(this.db, '.db required');
this.max = opts.max || 2500;
Expand Down Expand Up @@ -59,7 +58,6 @@ Limiter.prototype.inspect = function() {

Limiter.prototype.get = function (fn) {
var db = this.db;
var tidy = this.key;
var duration = this.duration;
var key = this.key;
var max = this.max;
Expand All @@ -73,9 +71,8 @@ Limiter.prototype.get = function (fn) {
['zrange', key, -max, -max],
['pexpire', key, duration],
]
if (tidy) {
operations.splice(5, 0, ['zremrangebyrank', key, 0, -(max + 1)])
}

operations.splice(5, 0, ['zremrangebyrank', key, 0, -(max + 1)])
db.multi(operations)
.exec(function (err, res) {
if (err) return fn(err);
Expand Down
Loading

0 comments on commit b958870

Please sign in to comment.