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