frequent; // Frequent LRU
recentGhost; // Recent history LRU
frequentGhost; // Frequent historic LRU
+ age; // Tally of total get attempts, for statistics
eventData; // Object spread over all event data
/**
capacity: frequentCapacity,
evictDestination: this.frequentGhost,
});
+
+ this.age = 0;
}
+ /**
+ * @returns {number} capacity of the cache
+ */
get capacity() {
return this._capacity;
}
+ /**
+ * @returns {number} capacity of the adaptive cache
+ */
get adaptiveCapacity() {
return this._adaptiveCapacity;
}
+ /**
+ * @returns {number} entries in the cache
+ */
get size() {
return this.recent.size + this.frequent.size + this.recentGhost.size + this.frequentGhost.size;
}
* @param {boolean} isGhost hit from ghost cache
*/
_hit(entry, isGhost = false) {
+ this.age += 1;
this.emit('hit', {
...this.eventData,
key: entry.key,
count: entry.count,
+ age: this.age - entry.ts,
isGhost,
});
}
* @param {*} key key
*/
_miss(key) {
+ this.age += 1;
this.emit('miss', {
...this.eventData,
key,