@postgresx/noredis 0.7.1 → 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-BD36RDOX.js → chunk-6D2PPDAW.js} +16 -5
- 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) {
|
|
@@ -287,11 +289,13 @@ var PgKvCache = class {
|
|
|
287
289
|
WHERE ctid IN (
|
|
288
290
|
SELECT ctid
|
|
289
291
|
FROM ${this.quotedTableName}
|
|
290
|
-
WHERE
|
|
291
|
-
|
|
292
|
+
WHERE namespace = $1
|
|
293
|
+
AND expires_at IS NOT NULL
|
|
294
|
+
AND expires_at <= NOW()
|
|
295
|
+
LIMIT $2
|
|
292
296
|
)
|
|
293
297
|
RETURNING namespace, key`,
|
|
294
|
-
[Math.max(1, Math.floor(limit))]
|
|
298
|
+
[this.namespace, Math.max(1, Math.floor(limit))]
|
|
295
299
|
);
|
|
296
300
|
for (const row of rows) {
|
|
297
301
|
if (row.namespace === this.namespace) this.deleteL1(row.key);
|
|
@@ -595,7 +599,9 @@ var PgKvCache = class {
|
|
|
595
599
|
namespace: this.namespace,
|
|
596
600
|
tableName: this.tableName,
|
|
597
601
|
l1Size: this.l1.size,
|
|
598
|
-
l1Max: this.l1Max
|
|
602
|
+
l1Max: this.l1Max,
|
|
603
|
+
l1Hits: this.l1Hits,
|
|
604
|
+
l1Misses: this.l1Misses
|
|
599
605
|
};
|
|
600
606
|
}
|
|
601
607
|
async publish(event) {
|
|
@@ -648,11 +654,16 @@ var PgKvCache = class {
|
|
|
648
654
|
getL1(key) {
|
|
649
655
|
if (!this.l1Enabled) return { hit: false };
|
|
650
656
|
const entry = this.l1.get(key);
|
|
651
|
-
if (!entry)
|
|
657
|
+
if (!entry) {
|
|
658
|
+
this.l1Misses += 1;
|
|
659
|
+
return { hit: false };
|
|
660
|
+
}
|
|
652
661
|
if (entry.expiresAt !== null && entry.expiresAt <= this.now()) {
|
|
653
662
|
this.l1.delete(key);
|
|
663
|
+
this.l1Misses += 1;
|
|
654
664
|
return { hit: false };
|
|
655
665
|
}
|
|
666
|
+
this.l1Hits += 1;
|
|
656
667
|
this.l1.delete(key);
|
|
657
668
|
this.l1.set(key, entry);
|
|
658
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