refactor: lru-cache maxAge to ttl (#8039)

This commit is contained in:
Antoine Cormouls
2022-06-13 15:29:50 +02:00
committed by GitHub
parent 5f7d392a06
commit 72fac8a5fc
5 changed files with 17 additions and 10 deletions

19
package-lock.json generated
View File

@@ -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": {

View File

@@ -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",

View File

@@ -5,7 +5,7 @@ export class LRUCache {
constructor({ ttl = defaults.cacheTTL, maxSize = defaults.cacheMaxSize }) {
this.cache = new LRU({
max: maxSize,
maxAge: ttl,
ttl,
});
}

View File

@@ -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(

View File

@@ -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,
});
}