Comparing version 0.0.84 to 0.0.85
@@ -1,2 +0,2 @@ | ||
/*! dw-cache v0.0.84 https://github.com/falsandtru/dw-cache | (c) 2021, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
/*! dw-cache v0.0.85 https://github.com/falsandtru/dw-cache | (c) 2021, falsandtru | (Apache-2.0 AND MPL-2.0) License */ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -417,3 +417,3 @@ if(typeof exports === 'object' && typeof module === 'object') | ||
}, | ||
life: { | ||
aging: { | ||
threshold: 90 | ||
@@ -456,3 +456,3 @@ }, | ||
this.sweeper = new Sweeper(this.indexes.LRU, settings.sweep.threshold, capacity, settings.sweep.window, settings.sweep.range, settings.sweep.shift); | ||
this.ager = new Clock(capacity, this.indexes.LFU, settings.life.threshold); | ||
this.ager = new Clock(capacity, this.indexes.LFU, settings.aging.threshold); | ||
this.disposer = settings.disposer; | ||
@@ -537,10 +537,7 @@ this.test = settings.test; | ||
const match = node !== undefined; | ||
if (!match) { | ||
this.sweeper.miss(); | ||
if (this.ager.isActive() && this.sweeper.isActive()) { | ||
const victim = this.ager.advance(); | ||
if (victim !== undefined) { | ||
this.indexes.LRU.unshiftNode(victim); | ||
++this.overlap; | ||
} | ||
if (!match && this.ager.isActive() && this.sweeper.isActive()) { | ||
const victim = this.ager.advance(); | ||
if (victim !== undefined) { | ||
this.indexes.LRU.unshiftNode(victim); | ||
++this.overlap; | ||
} | ||
@@ -598,5 +595,9 @@ } | ||
const node = this.memory.get(key); | ||
if (node === undefined) return; | ||
if (node === undefined) { | ||
this.sweeper.miss(); | ||
return; | ||
} | ||
const entry = node.value; | ||
if (this.expiration && entry.expiration !== Infinity && entry.expiration < (0, clock_1.now)()) { | ||
this.sweeper.miss(); | ||
this.evict(node, true); | ||
@@ -1013,3 +1014,3 @@ return; | ||
this.threshold = threshold; | ||
this.counter = 0; | ||
this.count = 0; | ||
} | ||
@@ -1033,9 +1034,7 @@ isActive() { | ||
advance() { | ||
if (this.counter++ === this.capacity) { | ||
this.hand = this.target.head; | ||
this.counter = 1; | ||
} else if (this.counter > this.target.length) { | ||
if (++this.count === this.capacity) { | ||
this.hand = undefined; | ||
this.count = 0; | ||
} else if (this.count > this.target.length) { | ||
return; | ||
} else if (this.counter > 0 && this.hand === this.target.head) { | ||
return; | ||
} | ||
@@ -1042,0 +1041,0 @@ let node = this.hand ??= this.target.head; |
{ | ||
"name": "dw-cache", | ||
"version": "0.0.84", | ||
"version": "0.0.85", | ||
"description": "The highest performance constant complexity cache algorithm.", | ||
@@ -53,3 +53,3 @@ "private": false, | ||
"npm-check-updates": "^16.4.3", | ||
"spica": "0.0.688", | ||
"spica": "0.0.689", | ||
"ts-loader": "^9.4.1", | ||
@@ -56,0 +56,0 @@ "typescript": "4.9.3", |
@@ -434,5 +434,5 @@ # Dual Window Cache | ||
LRU hit ratio 16.47% | ||
DWC hit ratio 18.09% | ||
DWC - LRU hit ratio delta 1.61% | ||
DWC / LRU hit ratio rate 109% | ||
DWC hit ratio 18.14% | ||
DWC - LRU hit ratio delta 1.67% | ||
DWC / LRU hit ratio rate 110% | ||
@@ -541,5 +541,5 @@ OLTP 500 | ||
LRU hit ratio 0.96% | ||
DWC hit ratio 31.34% | ||
DWC - LRU hit ratio delta 30.38% | ||
DWC / LRU hit ratio rate 3251% | ||
DWC hit ratio 31.36% | ||
DWC - LRU hit ratio delta 30.40% | ||
DWC / LRU hit ratio rate 3253% | ||
@@ -594,4 +594,4 @@ GLI 750 | ||
LRU hit ratio 0.00% | ||
DWC hit ratio 22.55% | ||
DWC - LRU hit ratio delta 22.55% | ||
DWC hit ratio 22.71% | ||
DWC - LRU hit ratio delta 22.71% | ||
DWC / LRU hit ratio rate Infinity% | ||
@@ -601,4 +601,4 @@ | ||
LRU hit ratio 0.00% | ||
DWC hit ratio 46.88% | ||
DWC - LRU hit ratio delta 46.88% | ||
DWC hit ratio 46.75% | ||
DWC - LRU hit ratio delta 46.75% | ||
DWC / LRU hit ratio rate Infinity% | ||
@@ -758,3 +758,3 @@ | ||
}; | ||
readonly life?: { | ||
readonly aging?: { | ||
readonly threshold?: number; | ||
@@ -761,0 +761,0 @@ }; |
114204
2179