@postgresx/noredis 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-YSQCYFKW.js → chunk-6D2PPDAW.js} +11 -2
- package/dist/index.js +1 -1
- package/dist/kv-cache.d.ts +6 -0
- package/dist/kv-cache.js +1 -1
- package/dist/kv.js +1 -1
- package/package.json +1 -1
|
@@ -81,6 +81,8 @@ var PgKvCache = class {
|
|
|
81
81
|
serializer;
|
|
82
82
|
l1 = /* @__PURE__ */ new Map();
|
|
83
83
|
l1Generation = 0;
|
|
84
|
+
l1Hits = 0;
|
|
85
|
+
l1Misses = 0;
|
|
84
86
|
invalidationListener = null;
|
|
85
87
|
invalidationReconnectUnsubscribe = null;
|
|
86
88
|
constructor(options) {
|
|
@@ -597,7 +599,9 @@ var PgKvCache = class {
|
|
|
597
599
|
namespace: this.namespace,
|
|
598
600
|
tableName: this.tableName,
|
|
599
601
|
l1Size: this.l1.size,
|
|
600
|
-
l1Max: this.l1Max
|
|
602
|
+
l1Max: this.l1Max,
|
|
603
|
+
l1Hits: this.l1Hits,
|
|
604
|
+
l1Misses: this.l1Misses
|
|
601
605
|
};
|
|
602
606
|
}
|
|
603
607
|
async publish(event) {
|
|
@@ -650,11 +654,16 @@ var PgKvCache = class {
|
|
|
650
654
|
getL1(key) {
|
|
651
655
|
if (!this.l1Enabled) return { hit: false };
|
|
652
656
|
const entry = this.l1.get(key);
|
|
653
|
-
if (!entry)
|
|
657
|
+
if (!entry) {
|
|
658
|
+
this.l1Misses += 1;
|
|
659
|
+
return { hit: false };
|
|
660
|
+
}
|
|
654
661
|
if (entry.expiresAt !== null && entry.expiresAt <= this.now()) {
|
|
655
662
|
this.l1.delete(key);
|
|
663
|
+
this.l1Misses += 1;
|
|
656
664
|
return { hit: false };
|
|
657
665
|
}
|
|
666
|
+
this.l1Hits += 1;
|
|
658
667
|
this.l1.delete(key);
|
|
659
668
|
this.l1.set(key, entry);
|
|
660
669
|
return { hit: true, value: entry.value };
|
package/dist/index.js
CHANGED
package/dist/kv-cache.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ interface PgKvCacheStats {
|
|
|
62
62
|
tableName: string;
|
|
63
63
|
l1Size: number;
|
|
64
64
|
l1Max: number;
|
|
65
|
+
/** Monotonic L1 read hits since the cache was created. */
|
|
66
|
+
l1Hits: number;
|
|
67
|
+
/** Monotonic L1 read misses (absent or expired) since the cache was created. */
|
|
68
|
+
l1Misses: number;
|
|
65
69
|
}
|
|
66
70
|
declare class PgKvCache {
|
|
67
71
|
readonly namespace: string;
|
|
@@ -78,6 +82,8 @@ declare class PgKvCache {
|
|
|
78
82
|
private readonly serializer;
|
|
79
83
|
private readonly l1;
|
|
80
84
|
private l1Generation;
|
|
85
|
+
private l1Hits;
|
|
86
|
+
private l1Misses;
|
|
81
87
|
private invalidationListener;
|
|
82
88
|
private invalidationReconnectUnsubscribe;
|
|
83
89
|
constructor(options: PgKvCacheOptions);
|
package/dist/kv-cache.js
CHANGED
package/dist/kv.js
CHANGED
package/package.json
CHANGED