@adaptic/utils 0.0.1009 → 0.0.1010

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/index.cjs CHANGED
@@ -63781,6 +63781,29 @@ class StampedeProtectedCache {
63781
63781
  has(key) {
63782
63782
  return this.cache.has(key);
63783
63783
  }
63784
+ /**
63785
+ * Synchronous peek at a cached value without triggering a loader.
63786
+ *
63787
+ * @description Returns the cached value when present and FRESH (inside its
63788
+ * per-entry TTL), `undefined` otherwise — never coalesces onto or starts a
63789
+ * load, never serves stale-while-revalidate data, and counts a hit only
63790
+ * when a fresh value is returned (mirroring the read-path hit semantics so
63791
+ * hitRatio stays truthful). Added 2026-08-08 for the engine cache
63792
+ * consolidation: its fork exposed peek() and consumers rely on the
63793
+ * no-load contract on hot paths.
63794
+ *
63795
+ * @param key - Cache key to inspect.
63796
+ * @returns The fresh cached value, or `undefined` when absent or expired.
63797
+ */
63798
+ peek(key) {
63799
+ const entry = this.cache.get(key);
63800
+ if (entry && Date.now() < entry.expiresAt) {
63801
+ this.stats.hits++;
63802
+ this.emitEvent("hit", key);
63803
+ return entry.value;
63804
+ }
63805
+ return undefined;
63806
+ }
63784
63807
  /**
63785
63808
  * Delete a specific key from the cache
63786
63809
  *