New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dw-cache

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dw-cache - npm Package Compare versions

Comparing version 0.0.43 to 0.0.44

49

dist/index.js

@@ -1,2 +0,2 @@

/*! dw-cache v0.0.43 https://github.com/falsandtru/dw-cache | (c) 2021, falsandtru | (Apache-2.0 AND MPL-2.0) License */
/*! dw-cache v0.0.44 https://github.com/falsandtru/dw-cache | (c) 2021, falsandtru | (Apache-2.0 AND MPL-2.0) License */
(function webpackUniversalModuleDefinition(root, factory) {

@@ -363,4 +363,2 @@ if(typeof exports === 'object' && typeof module === 'object')

window: 0,
resolution: 1,
offset: 0,
capacity: 0,

@@ -370,8 +368,10 @@ space: global_1.Infinity,

earlyExpiring: false,
interval: 0,
limit: 950,
capture: {
delete: true,
clear: true
}
},
resolution: 1,
offset: 0,
sweep: 50,
limit: 950
};

@@ -387,2 +387,3 @@ this.overlap = 0;

this.misses = 0;
this.sweep = 0;
this.ratio = 500;

@@ -403,3 +404,2 @@

this.space = settings.space;
this.interval = settings.interval || (0, alias_1.sqrt)(this.capacity) | 0 || 1;
this.limit = settings.limit;

@@ -433,3 +433,3 @@ this.earlyExpiring = settings.earlyExpiring;

let size = skip?.value.size ?? 0;
if (margin - size <= 0) return;
if (margin - size <= 0) return true;
const {

@@ -463,4 +463,11 @@ LRU,

default:
if (this.misses >= LRU.length) {
LRU.head = this.misses % this.interval === 0 ? LRU.head.next.next : LRU.head.next;
if (this.misses > LRU.length) {
this.sweep ||= this.sweep = LRU.length * this.settings.sweep / 100 | 0 || 1;
if (this.sweep > 0) {
LRU.head = this.misses === LRU.length + 1 ? LRU.head.next : LRU.head.next.next;
this.sweep === 1 ? this.sweep = -LRU.length * this.settings.sweep / 100 | 0 : --this.sweep;
} else {
this.sweep === -1 ? LRU.head = LRU.head.next : ++this.sweep;
}
}

@@ -475,2 +482,4 @@

}
return !!skip?.list;
}

@@ -490,6 +499,5 @@

if (node) {
if (node && this.ensure(size, node)) {
const val = node.value.value;
const index = node.value;
this.ensure(size, node);
this.SIZE += size - index.size;

@@ -538,4 +546,9 @@ index.size = size;

const node = this.memory.get(key);
node ? this.misses &&= 0 : ++this.misses;
if (!node) return;
if (!node) {
++this.misses;
return;
}
this.misses &&= 0;
const expiry = node.value.expiry;

@@ -622,6 +635,6 @@

const lenO = this.overlap;
const r = (lenF + lenO) * 1000 / (lenR + lenF) | 0;
const rateR0 = stats.rateLRU() * r;
const rateF0 = stats.rateLFU() * (1000 - r);
const rateF1 = stats.offset && stats.rateLFU(true) * (1000 - r); // 操作頻度を超えてキャッシュ比率を増減させても余剰比率の消化が追いつかず無駄
const leverage = (lenF + lenO) * 1000 / (lenR + lenF) | 0;
const rateR0 = stats.rateLRU() * leverage;
const rateF0 = stats.rateLFU() * (1000 - leverage);
const rateF1 = stats.offset && stats.rateLFU(true) * (1000 - leverage); // 操作頻度を超えてキャッシュ比率を増減させても余剰比率の消化が追いつかず無駄
// LRUの下限設定ではLRU拡大の要否を迅速に判定できないためLFUのヒット率低下の検出で代替する

@@ -628,0 +641,0 @@

{
"name": "dw-cache",
"version": "0.0.43",
"version": "0.0.44",
"description": "Dual window cache adaptively coordinates the ratio of LRU to LFU using the two sliding windows.",

@@ -53,3 +53,3 @@ "private": false,

"npm-check-updates": "^16.0.1",
"spica": "0.0.585",
"spica": "0.0.586",
"ts-loader": "^9.3.1",

@@ -56,0 +56,0 @@ "typescript": "4.7.4",

@@ -57,6 +57,18 @@ # Dual Window Cache

LRU hit rate 16.4%
DWC hit rate 18.1%
DWC - LRU hit rate delta 1.6%
DWC / LRU hit rate ratio 110%
DWC hit rate 18.0%
DWC - LRU hit rate delta 1.5%
DWC / LRU hit rate ratio 109%
OLTP 500
LRU hit rate 23.4%
DWC hit rate 28.9%
DWC - LRU hit rate delta 5.4%
DWC / LRU hit rate ratio 123%
OLTP 750
LRU hit rate 28.2%
DWC hit rate 34.7%
DWC - LRU hit rate delta 6.4%
DWC / LRU hit rate ratio 122%
OLTP 1,000

@@ -80,4 +92,4 @@ LRU hit rate 32.8%

LRU hit rate 0%
DWC hit rate 0.7%
DWC - LRU hit rate delta 0.7%
DWC hit rate 9.5%
DWC - LRU hit rate delta 9.5%
DWC / LRU hit rate ratio Infinity

@@ -87,4 +99,4 @@

LRU hit rate 0%
DWC hit rate 19.8%
DWC - LRU hit rate delta 19.8%
DWC hit rate 23.8%
DWC - LRU hit rate delta 23.8%
DWC / LRU hit rate ratio Infinity

@@ -94,4 +106,4 @@

LRU hit rate 0%
DWC hit rate 46.9%
DWC - LRU hit rate delta 46.9%
DWC hit rate 47.4%
DWC - LRU hit rate delta 47.4%
DWC / LRU hit rate ratio Infinity

@@ -101,4 +113,4 @@

LRU hit rate 0%
DWC hit rate 70.8%
DWC - LRU hit rate delta 70.8%
DWC hit rate 70.7%
DWC - LRU hit rate delta 70.7%
DWC / LRU hit rate ratio Infinity

@@ -108,4 +120,4 @@

LRU hit rate 0%
DWC hit rate 95.1%
DWC - LRU hit rate delta 95.1%
DWC hit rate 94.6%
DWC - LRU hit rate delta 94.6%
DWC / LRU hit rate ratio Infinity

@@ -157,24 +169,24 @@

```
'LRUCache simulation 100 x 5,161,510 ops/sec ±2.47% (58 runs sampled)'
'LRUCache simulation 100 x 7,864,193 ops/sec ±0.44% (67 runs sampled)'
'DW-Cache simulation 100 x 3,699,800 ops/sec ±1.56% (60 runs sampled)'
'DW-Cache simulation 100 x 4,833,508 ops/sec ±0.32% (68 runs sampled)'
'LRUCache simulation 1,000 x 4,374,297 ops/sec ±0.62% (61 runs sampled)'
'LRUCache simulation 1,000 x 7,407,931 ops/sec ±0.46% (66 runs sampled)'
'DW-Cache simulation 1,000 x 3,111,354 ops/sec ±3.63% (58 runs sampled)'
'DW-Cache simulation 1,000 x 4,204,219 ops/sec ±0.33% (63 runs sampled)'
'LRUCache simulation 10,000 x 4,603,830 ops/sec ±2.30% (61 runs sampled)'
'LRUCache simulation 10,000 x 6,872,077 ops/sec ±1.96% (62 runs sampled)'
'DW-Cache simulation 10,000 x 2,754,571 ops/sec ±3.38% (55 runs sampled)'
'DW-Cache simulation 10,000 x 3,734,782 ops/sec ±1.99% (62 runs sampled)'
'LRUCache simulation 100,000 x 3,059,272 ops/sec ±1.63% (59 runs sampled)'
'LRUCache simulation 100,000 x 3,004,533 ops/sec ±1.48% (57 runs sampled)'
'DW-Cache simulation 100,000 x 1,625,055 ops/sec ±7.78% (49 runs sampled)'
'DW-Cache simulation 100,000 x 1,531,634 ops/sec ±2.91% (59 runs sampled)'
'LRUCache simulation 1,000,000 x 1,700,876 ops/sec ±5.18% (51 runs sampled)'
'LRUCache simulation 1,000,000 x 1,738,064 ops/sec ±3.55% (52 runs sampled)'
'DW-Cache simulation 1,000,000 x 836,083 ops/sec ±8.45% (53 runs sampled)'
'DW-Cache simulation 1,000,000 x 1,003,836 ops/sec ±7.02% (52 runs sampled)'
```
https://github.com/falsandtru/spica/runs/6751777283
https://github.com/falsandtru/spica/runs/7560221542

@@ -187,4 +199,2 @@ ## API

readonly window?: number;
readonly resolution?: number;
readonly offset?: number;
readonly capacity?: number;

@@ -194,4 +204,2 @@ readonly space?: number;

readonly earlyExpiring?: boolean;
readonly interval?: number;
readonly limit?: number;
readonly disposer?: (value: V, key: K) => void;

@@ -202,2 +210,7 @@ readonly capture?: {

};
// Mainly for experiments.
readonly resolution?: number;
readonly offset?: number;
readonly sweep?: number;
readonly limit?: number;
}

@@ -204,0 +217,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc