Comparing version 0.0.727 to 0.0.728
28
cache.ts
@@ -107,3 +107,3 @@ import { max, min, floor, round } from './alias'; | ||
public partition: 'LRU' | 'LFU', | ||
public region: 'LRU' | 'LFU', | ||
public affiliation: 'LRU' | 'LFU', | ||
public expiration: number, | ||
@@ -171,3 +171,3 @@ ) { | ||
if (capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`); | ||
this.window = capacity * settings.window! / 100 >>> 0; | ||
this.window = capacity * settings.window! / 100 >>> 0 || 1; | ||
this.partition = capacity - this.window; | ||
@@ -240,3 +240,3 @@ this.injection = 100 * this.declination; | ||
const { settings } = this; | ||
this.window = capacity * settings.window! / 100 >>> 0; | ||
this.window = capacity * settings.window! / 100 >>> 0 || 1; | ||
this.resource = resource ?? settings.resource ?? capacity; | ||
@@ -295,3 +295,3 @@ this.sweeper.resize( | ||
if (entry.partition === 'LRU') { | ||
if (entry.region === 'LRU') { | ||
if (entry.affiliation === 'LRU') { | ||
if (eviction) return entry; | ||
@@ -307,3 +307,3 @@ ++this.overlapLRU; | ||
else { | ||
if (entry.region === 'LFU') { | ||
if (entry.affiliation === 'LFU') { | ||
if (eviction) return entry; | ||
@@ -316,3 +316,3 @@ ++this.overlapLFU; | ||
assert(this.overlapLRU >= 0); | ||
if (this.overlapLRU * 100 < this.LFU.length * this.sample) { | ||
if (this.declination !== 1 && this.overlapLRU * 100 < this.LFU.length * this.sample) { | ||
this.declination = 1; | ||
@@ -365,3 +365,3 @@ } | ||
const entry = LRU.head!.prev!; | ||
if (entry.region === 'LRU') { | ||
if (entry.affiliation === 'LRU') { | ||
LRU.delete(entry); | ||
@@ -438,7 +438,7 @@ LFU.unshift(this.overlap(entry)); | ||
if (entry.partition === 'LRU') { | ||
if (entry.region === 'LRU') { | ||
if (entry.affiliation === 'LRU') { | ||
// For memoize. | ||
// Strict checks are ineffective for OLTP. | ||
if (entry === LRU.head) return; | ||
entry.region = 'LFU'; | ||
entry.affiliation = 'LFU'; | ||
} | ||
@@ -461,3 +461,3 @@ else { | ||
else { | ||
if (entry.region === 'LFU') { | ||
if (entry.affiliation === 'LFU') { | ||
} | ||
@@ -471,6 +471,6 @@ else { | ||
this.partition = max(this.partition - delta, 0); | ||
entry.region = 'LFU'; | ||
entry.affiliation = 'LFU'; | ||
--this.overlapLRU; | ||
assert(this.overlapLRU >= 0); | ||
if (this.overlapLRU * 100 < this.LFU.length * this.sample) { | ||
if (this.declination !== 1 && this.overlapLRU * 100 < this.LFU.length * this.sample) { | ||
this.declination = 1; | ||
@@ -511,3 +511,3 @@ } | ||
assert(victim === LRU.head!.prev); | ||
victim.region === 'LFU' && --this.overlapLFU; | ||
victim.affiliation === 'LFU' && --this.overlapLFU; | ||
assert(this.overlapLFU >= 0); | ||
@@ -518,3 +518,3 @@ this.dict.delete(victim.key); | ||
assert(this.dict.size <= this.capacity); | ||
victim.region = 'LRU'; | ||
victim.affiliation = 'LRU'; | ||
LRU.head = victim; | ||
@@ -521,0 +521,0 @@ this.update(victim, key, value, size, expiration); |
{ | ||
"name": "spica", | ||
"version": "0.0.727", | ||
"version": "0.0.728", | ||
"description": "Supervisor, Coroutine, Channel, select, AtomicPromise, Cancellation, Cache, List, Queue, Stack, and some utils.", | ||
@@ -80,3 +80,3 @@ "private": false, | ||
"typescript": "5.0.4", | ||
"webpack": "^5.84.0", | ||
"webpack": "^5.84.1", | ||
"webpack-cli": "^5.1.1", | ||
@@ -83,0 +83,0 @@ "webpack-merge": "^5.9.0", |
@@ -107,3 +107,3 @@ import { max, min, floor, round } from './alias'; | ||
public partition: 'LRU' | 'LFU', | ||
public region: 'LRU' | 'LFU', | ||
public affiliation: 'LRU' | 'LFU', | ||
public expiration: number, | ||
@@ -171,3 +171,3 @@ ) { | ||
if (capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`); | ||
this.window = capacity * settings.window! / 100 >>> 0; | ||
this.window = capacity * settings.window! / 100 >>> 0 || 1; | ||
this.partition = capacity - this.window; | ||
@@ -240,3 +240,3 @@ this.injection = 100 * this.declination; | ||
const { settings } = this; | ||
this.window = capacity * settings.window! / 100 >>> 0; | ||
this.window = capacity * settings.window! / 100 >>> 0 || 1; | ||
this.resource = resource ?? settings.resource ?? capacity; | ||
@@ -295,3 +295,3 @@ this.sweeper.resize( | ||
if (entry.partition === 'LRU') { | ||
if (entry.region === 'LRU') { | ||
if (entry.affiliation === 'LRU') { | ||
if (eviction) return entry; | ||
@@ -307,3 +307,3 @@ ++this.overlapLRU; | ||
else { | ||
if (entry.region === 'LFU') { | ||
if (entry.affiliation === 'LFU') { | ||
if (eviction) return entry; | ||
@@ -316,3 +316,3 @@ ++this.overlapLFU; | ||
assert(this.overlapLRU >= 0); | ||
if (this.overlapLRU * 100 < this.LFU.length * this.sample) { | ||
if (this.declination !== 1 && this.overlapLRU * 100 < this.LFU.length * this.sample) { | ||
this.declination = 1; | ||
@@ -365,3 +365,3 @@ } | ||
const entry = LRU.head!.prev!; | ||
if (entry.region === 'LRU') { | ||
if (entry.affiliation === 'LRU') { | ||
LRU.delete(entry); | ||
@@ -438,7 +438,7 @@ LFU.unshift(this.overlap(entry)); | ||
if (entry.partition === 'LRU') { | ||
if (entry.region === 'LRU') { | ||
if (entry.affiliation === 'LRU') { | ||
// For memoize. | ||
// Strict checks are ineffective for OLTP. | ||
if (entry === LRU.head) return; | ||
entry.region = 'LFU'; | ||
entry.affiliation = 'LFU'; | ||
} | ||
@@ -461,3 +461,3 @@ else { | ||
else { | ||
if (entry.region === 'LFU') { | ||
if (entry.affiliation === 'LFU') { | ||
} | ||
@@ -471,6 +471,6 @@ else { | ||
this.partition = max(this.partition - delta, 0); | ||
entry.region = 'LFU'; | ||
entry.affiliation = 'LFU'; | ||
--this.overlapLRU; | ||
assert(this.overlapLRU >= 0); | ||
if (this.overlapLRU * 100 < this.LFU.length * this.sample) { | ||
if (this.declination !== 1 && this.overlapLRU * 100 < this.LFU.length * this.sample) { | ||
this.declination = 1; | ||
@@ -511,3 +511,3 @@ } | ||
assert(victim === LRU.head!.prev); | ||
victim.region === 'LFU' && --this.overlapLFU; | ||
victim.affiliation === 'LFU' && --this.overlapLFU; | ||
assert(this.overlapLFU >= 0); | ||
@@ -518,3 +518,3 @@ this.dict.delete(victim.key); | ||
assert(this.dict.size <= this.capacity); | ||
victim.region = 'LRU'; | ||
victim.affiliation = 'LRU'; | ||
LRU.head = victim; | ||
@@ -521,0 +521,0 @@ this.update(victim, key, value, size, expiration); |
@@ -112,3 +112,3 @@ const path = require('path'); | ||
// ignore: './**/*.test.ts', | ||
// }).map(path => [path.match(/[\w.]+(?=\.)/)[0], path])).sort(), | ||
// }).map(path => [path.match(/[\w.]+(?=\.)/)[0], path]).sort()), | ||
// output: { | ||
@@ -115,0 +115,0 @@ // filename: '[name].js', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1154979