Grow cache size dynamically

This commit is contained in:
Andreas Hocevar
2020-07-11 11:30:01 +02:00
parent 5cd102af10
commit 0167c2760e
15 changed files with 40 additions and 21 deletions

View File

@@ -27,6 +27,8 @@ class LRUCache {
*/
constructor(opt_highWaterMark) {
/**
* Desired max cache size after expireCache(). If set to 0, no cache entries
* will be pruned at all.
* @type {number}
*/
this.highWaterMark =
@@ -61,7 +63,7 @@ class LRUCache {
* @return {boolean} Can expire cache.
*/
canExpireCache() {
return this.getCount() > this.highWaterMark;
return this.highWaterMark > 0 && this.getCount() > this.highWaterMark;
}
/**