Skip to content

Commit

Permalink
Remove expired rate_conn hash keys (#66)
Browse files Browse the repository at this point in the history
closes #65
  • Loading branch information
jonmz authored Jul 17, 2024
1 parent 58a35ca commit 89b4769
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,10 @@ exports.rate_conn_enforce = async function (next, connection) {

let connections_in_ttl_period = 0
for (const ts of Object.keys(tstamps)) {
if (parseInt(ts, 10) < periodStartTs) continue // older than ttl
if (parseInt(ts, 10) < periodStartTs) { // older than ttl
this.db.hDel(`rate_conn:${key}`, ts);
continue
}
connections_in_ttl_period =
connections_in_ttl_period + parseInt(tstamps[ts], 10)
}
Expand Down

0 comments on commit 89b4769

Please sign in to comment.