Skip to content

Commit ce7fa89

Browse files
committed
f
1 parent 7528d98 commit ce7fa89

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

lib/api/apiUtils/rateLimit/cache.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ function getCachedConfig(key) {
4848

4949
function expireCachedConfigs(now) {
5050
const toRemove = [];
51-
for (const [key, { expiry }] of counters.entries()) {
51+
for (const [key, { expiry }] of configCache.entries()) {
5252
if (expiry <= now) {
5353
toRemove.push(key);
5454
}
5555
}
5656

5757
for (const key of toRemove) {
58-
counters.delete(key);
58+
configCache.delete(key);
5959
}
6060
}
6161

tests/unit/api/apiUtils/rateLimit/cache.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ describe('test limit config cache storage', () => {
100100
config: 10,
101101
});
102102
expireCachedConfigs(now);
103-
assert.strictEqual(getCachedConfig('past'), undefined);
104-
assert.strictEqual(getCachedConfig('present'), undefined);
105-
assert.strictEqual(getCachedConfig('future'), 10);
103+
assert.strictEqual(configCache.get('past'), undefined);
104+
assert.strictEqual(configCache.get('present'), undefined);
105+
assert.deepStrictEqual(configCache.get('future'), {
106+
expiry: now + 10000,
107+
config: 10,
108+
});
106109
});
107110
});

0 commit comments

Comments
 (0)