@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.
@@ -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) return { hit: false };
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
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  PgKvCache,
11
11
  createPgKvCache
12
- } from "./chunk-YSQCYFKW.js";
12
+ } from "./chunk-6D2PPDAW.js";
13
13
  import {
14
14
  PgList,
15
15
  createPgList
@@ -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
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PgKvCache,
3
3
  createPgKvCache
4
- } from "./chunk-YSQCYFKW.js";
4
+ } from "./chunk-6D2PPDAW.js";
5
5
  export {
6
6
  PgKvCache,
7
7
  createPgKvCache
package/dist/kv.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PgKvCache,
3
3
  createPgKvCache
4
- } from "./chunk-YSQCYFKW.js";
4
+ } from "./chunk-6D2PPDAW.js";
5
5
  export {
6
6
  PgKvCache,
7
7
  createPgKvCache
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postgresx/noredis",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "PostgreSQL-backed Redis feature replacement toolkit: KV/TTL cache, pub/sub, advisory locks, rate limiting, and pg-boss queues",
5
5
  "type": "module",
6
6
  "license": "MIT",