@warlock.js/cache 5.23.2 → 5.25.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/CHANGELOG.md +12 -0
- package/README.md +616 -616
- package/cjs/index.cjs +21 -1
- package/cjs/index.cjs.map +1 -1
- package/esm/drivers/base-cache-driver.d.mts +12 -0
- package/esm/drivers/base-cache-driver.d.mts.map +1 -1
- package/esm/drivers/base-cache-driver.mjs +10 -0
- package/esm/drivers/base-cache-driver.mjs.map +1 -1
- package/esm/drivers/null-cache-driver.mjs.map +1 -1
- package/esm/tagged-cache.d.mts.map +1 -1
- package/esm/tagged-cache.mjs +11 -1
- package/esm/tagged-cache.mjs.map +1 -1
- package/esm/types.d.mts +5 -2
- package/esm/types.d.mts.map +1 -1
- package/esm/types.mjs.map +1 -1
- package/esm/utils.mjs.map +1 -1
- package/llms-full.txt +1632 -1631
- package/llms.txt +1 -1
- package/package.json +3 -3
- package/skills/apply-cache-patterns/SKILL.md +95 -95
- package/skills/configure-set-options/SKILL.md +96 -96
- package/skills/handle-cache-errors/SKILL.md +92 -92
- package/skills/observe-cache/SKILL.md +104 -103
- package/skills/pick-cache-driver/SKILL.md +121 -121
- package/skills/test-cache-code/SKILL.md +219 -219
- package/skills/use-cache-atomic/SKILL.md +42 -42
- package/skills/use-cache-bulk/SKILL.md +57 -57
- package/skills/use-cache-list/SKILL.md +85 -85
- package/skills/use-cache-lock/SKILL.md +101 -101
- package/skills/use-cache-namespace/SKILL.md +88 -88
- package/skills/use-cache-similarity/SKILL.md +94 -94
- package/skills/use-cache-update-merge/SKILL.md +84 -84
- package/skills/use-cache-utils/SKILL.md +89 -89
- package/skills/use-cached-hof/SKILL.md +93 -93
- package/skills/use-swr/SKILL.md +104 -104
package/cjs/index.cjs
CHANGED
|
@@ -1839,12 +1839,22 @@ var TaggedCache = class TaggedCache {
|
|
|
1839
1839
|
* Invalidate (clear) all keys associated with the current tags
|
|
1840
1840
|
*/
|
|
1841
1841
|
async invalidate() {
|
|
1842
|
+
const startedAt = performance.now();
|
|
1843
|
+
const removed = /* @__PURE__ */ new Set();
|
|
1842
1844
|
for (const tag of this.cacheTags) {
|
|
1843
1845
|
const tagKey = this.tagKey(tag);
|
|
1844
1846
|
const members = await this.membersOf(tagKey);
|
|
1845
|
-
for (const member of members)
|
|
1847
|
+
for (const member of members) {
|
|
1848
|
+
await this.driver.remove(member);
|
|
1849
|
+
removed.add(member);
|
|
1850
|
+
}
|
|
1846
1851
|
await this.removeFromTag(tagKey, members);
|
|
1847
1852
|
}
|
|
1853
|
+
await this.driver.emitTagsInvalidated?.({
|
|
1854
|
+
tags: [...this.cacheTags],
|
|
1855
|
+
keys: [...removed],
|
|
1856
|
+
durationMs: performance.now() - startedAt
|
|
1857
|
+
});
|
|
1848
1858
|
}
|
|
1849
1859
|
/**
|
|
1850
1860
|
* Remove `indexedKey` from every tag of this handle.
|
|
@@ -2427,6 +2437,16 @@ var BaseCacheDriver = class {
|
|
|
2427
2437
|
return new TaggedCache(tags, this);
|
|
2428
2438
|
}
|
|
2429
2439
|
/**
|
|
2440
|
+
* Emit `invalidated` on behalf of a {@link TaggedCache} created by this
|
|
2441
|
+
* driver, once per `invalidate()` call. Listeners cannot fail the
|
|
2442
|
+
* invalidation: `emit` isolates them.
|
|
2443
|
+
*
|
|
2444
|
+
* @internal
|
|
2445
|
+
*/
|
|
2446
|
+
async emitTagsInvalidated(data) {
|
|
2447
|
+
await this.emit("invalidated", data);
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2430
2450
|
* {@inheritdoc}
|
|
2431
2451
|
*
|
|
2432
2452
|
* Default implementation: read → transform → write, serialized per key in
|