From 72fac8a5fc5ed75e645692c51faaaf53df60bfb5 Mon Sep 17 00:00:00 2001 From: Antoine Cormouls Date: Mon, 13 Jun 2022 15:29:50 +0200 Subject: [PATCH] refactor: lru-cache maxAge to ttl (#8039) --- package-lock.json | 19 +++++++++++++------ package.json | 2 +- src/Adapters/Cache/LRUCache.js | 2 +- src/LiveQuery/ParseLiveQueryServer.js | 2 +- src/LiveQuery/SessionTokenCache.js | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 05adf2dc4f..d5c8fa77b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9170,12 +9170,9 @@ "dev": true }, "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "requires": { - "yallist": "^4.0.0" - } + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.10.1.tgz", + "integrity": "sha512-BQuhQxPuRl79J5zSXRP+uNzPOyZw2oFI9JLRQ80XswSvg21KMKNtQza9eF42rfI/3Z40RvzBdXgziEkudzjo8A==" }, "lru-memoizer": { "version": "2.1.4", @@ -14421,6 +14418,16 @@ "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "requires": { "lru-cache": "^6.0.0" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + } } }, "semver-compare": { diff --git a/package.json b/package.json index 604e5ffb15..78d8b97d59 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "jwks-rsa": "2.1.3", "ldapjs": "2.3.2", "lodash": "4.17.21", - "lru-cache": "6.0.0", + "lru-cache": "7.10.1", "mime": "3.0.0", "mongodb": "4.6.0", "mustache": "4.2.0", diff --git a/src/Adapters/Cache/LRUCache.js b/src/Adapters/Cache/LRUCache.js index 889ca3d015..a07d0347eb 100644 --- a/src/Adapters/Cache/LRUCache.js +++ b/src/Adapters/Cache/LRUCache.js @@ -5,7 +5,7 @@ export class LRUCache { constructor({ ttl = defaults.cacheTTL, maxSize = defaults.cacheMaxSize }) { this.cache = new LRU({ max: maxSize, - maxAge: ttl, + ttl, }); } diff --git a/src/LiveQuery/ParseLiveQueryServer.js b/src/LiveQuery/ParseLiveQueryServer.js index 3a91797a2f..88e98ce233 100644 --- a/src/LiveQuery/ParseLiveQueryServer.js +++ b/src/LiveQuery/ParseLiveQueryServer.js @@ -64,7 +64,7 @@ class ParseLiveQueryServer { // The main benefit is to be able to reuse the same user / session token resolution. this.authCache = new LRU({ max: 500, // 500 concurrent - maxAge: config.cacheTimeout, + ttl: config.cacheTimeout, }); // Initialize websocket server this.parseWebSocketServer = new ParseWebSocketServer( diff --git a/src/LiveQuery/SessionTokenCache.js b/src/LiveQuery/SessionTokenCache.js index 0eb4c2ead5..13b84c7367 100644 --- a/src/LiveQuery/SessionTokenCache.js +++ b/src/LiveQuery/SessionTokenCache.js @@ -19,7 +19,7 @@ class SessionTokenCache { constructor(timeout: number = 30 * 24 * 60 * 60 * 1000, maxSize: number = 10000) { this.cache = new LRU({ max: maxSize, - maxAge: timeout, + ttl: timeout, }); }