@blaze-cache/core 0.1.1 → 0.2.1-beta

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/README.md CHANGED
@@ -15,9 +15,12 @@ also usable on its own.
15
15
  ## Install
16
16
 
17
17
  ```sh
18
- npm install @blaze-cache/core
18
+ npm install @blaze-cache/core@beta
19
19
  ```
20
20
 
21
+ `@beta` is npm's dist-tag for the prerelease; drop it to install the last stable
22
+ release.
23
+
21
24
  ## Quick start
22
25
 
23
26
  ```ts
@@ -28,6 +31,9 @@ const cache = await createCache({ capacity: 1000, persistence: { namespace: 'app
28
31
  cache.set('user:42', { name: 'Ada' }, { ttlMs: 30_000, tags: ['user:42'] });
29
32
 
30
33
  cache.get('user:42'); // { name: 'Ada' } — counted as a hit
34
+ cache.peek('user:42'); // the same value, with no hit recorded
35
+ cache.ttl('user:42'); // ~30000 — ms until it expires
36
+ cache.touch('user:42', { ttlMs: 60_000 }); // renew the deadline, keep the value
31
37
  cache.invalidateTags('user:42'); // removes it, synchronously, and syncs IndexedDB
32
38
  cache.stats(); // { hits, misses, evictions, expirations, … }
33
39
  ```
@@ -48,8 +54,17 @@ cache.stats(); // { hits, misses, evictions, expirations,
48
54
 
49
55
  * **Types are bundled** — no `@types/*` packages to install.
50
56
  * **ESM only, browser only.** Node/SSR targets are out of scope by design.
57
+ * **Values are shared by reference** — `set` hands the object over and `get`/`peek`/
58
+ `entry` hand the same object back, so mutating it rewrites the cache (and, after the
59
+ next flush, the persisted row). Clone on the way out if you need to edit: the sharing
60
+ is what keeps `get`/`set` allocation-free.
51
61
  * **Persistence is optional** and off by default; a blocked IndexedDB (private mode)
52
- degrades to memory-only instead of breaking the app.
62
+ degrades to memory-only instead of breaking the app. A flush that fails later — a quota
63
+ error, a transient IndexedDB problem — is logged and its records go straight back on
64
+ the queue for the next flush, rather than being dropped.
65
+ * **`capacity` is normalised** — below `1` clamps up, above `1_000_000` clamps down, and
66
+ a non-finite value falls back to the wasm default — so `capacity()` reports a real
67
+ number back.
53
68
 
54
69
  ## Documentation
55
70
 
package/dist/cache.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BlazeCacheLike, CacheEntry, CacheListener, CacheStats, SetOptions } from './types.js';
1
+ import type { BlazeCacheLike, CacheEntry, CacheListener, CacheStats, SetOptions, TouchOptions } from './types.js';
2
2
  import type { WasmInitInput } from './wasm.js';
3
3
  import type { CachePersistence, IndexedDbOptions } from './persistence/types.js';
4
4
  /** Entries held when `capacity` is not given. */
@@ -22,7 +22,14 @@ export interface IndexedDbPersistenceOptions extends IndexedDbOptions {
22
22
  }
23
23
  /** Options accepted by {@link BlazeCache.create}. */
24
24
  export interface BlazeCacheOptions {
25
- /** Maximum number of entries kept in memory (clamped to `>= 1`). Default {@link DEFAULT_CAPACITY}. */
25
+ /**
26
+ * Maximum number of entries kept in memory. The wasm binding normalises it before it is
27
+ * ever used: below `1` clamps up, above `1_000_000` clamps down, and a non-finite value
28
+ * (`NaN`, `Infinity`) falls back to the wasm default of 1024. Pass a value inside that
29
+ * range to be sure of what {@link BlazeCache.capacity} reports back.
30
+ *
31
+ * Default {@link DEFAULT_CAPACITY}.
32
+ */
26
33
  capacity?: number;
27
34
  /**
28
35
  * Durable storage. `false`/omitted means memory only.
@@ -48,10 +55,39 @@ export interface BlazeCacheOptions {
48
55
  * const cache = await createCache({ capacity: 1000, persistence: { namespace: 'app' } });
49
56
  * cache.set('user:42', { name: 'Ada' }, { ttlMs: 30_000, tags: ['user:42'] });
50
57
  * cache.get('user:42'); // { name: 'Ada' } — counted as a hit
58
+ * cache.peek('user:42'); // the same value, no hit recorded
59
+ * cache.ttl('user:42'); // ~30000 — ms until it expires
60
+ * cache.touch('user:42', { ttlMs: 60_000 }); // renew the deadline, keep the value
51
61
  * cache.invalidateTags('user:42'); // removes it and syncs IndexedDB
52
62
  * await cache.dispose();
53
63
  * ```
54
64
  *
65
+ * ### Value ownership
66
+ *
67
+ * Values are held — and handed back — **by reference**. The object you pass to
68
+ * {@link BlazeCache.set} is the very object {@link BlazeCache.get}, {@link BlazeCache.peek},
69
+ * {@link BlazeCache.entry} and {@link BlazeCache.entries} return later: mutating either one
70
+ * silently rewrites the cache — and, after the next flush, the persisted row — with no error
71
+ * and no warning. Treat values living in the cache as read-only: clone on the way *out*
72
+ * (`structuredClone(cache.get(key))`) before editing, or clone on the way *in* if you want
73
+ * to keep mutating your own copy. The sharing is deliberate, not an oversight — the Rust
74
+ * core promises allocation-free `get`/`set` precisely *because* values are never cloned or
75
+ * serialised on the hot path, and cloning on read would only close one half of the alias
76
+ * anyway (your original reference from `set` survives either way). The contract is
77
+ * ownership transfer, not deep-copy semantics.
78
+ *
79
+ * ### Multiple tabs
80
+ *
81
+ * Tabs share one IndexedDB namespace but nothing else: each one holds its own WebAssembly
82
+ * instance, hydrated once at startup, and each flushes the keys it wrote. There is no
83
+ * coordination between them — writes are last-writer-wins per key. For ordinary use that is
84
+ * what you want (the tab in the foreground refetches on focus and rewrites its own fresh
85
+ * copy), but a tab that keeps working while hidden — a timer, a background sync — can flush
86
+ * a value older than the one the focused tab just wrote, and after a reload that older
87
+ * value is what hydration paints until revalidation corrects it. If that matters, use a
88
+ * short `ttlMs` on records written from background tabs, or filter on a timestamp you store
89
+ * inside the value itself.
90
+ *
55
91
  * All reads and writes are synchronous — the wasm module is instantiated during `create`, so
56
92
  * the hot path never touches a `Promise`.
57
93
  */
@@ -65,13 +101,41 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
65
101
  * console warning instead of rejecting.
66
102
  */
67
103
  static create<V = any>(options?: BlazeCacheOptions): Promise<BlazeCache<V>>;
68
- /** Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss. */
104
+ /**
105
+ * Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss.
106
+ *
107
+ * The value comes back as the cache's **live reference** — see *Value ownership* on the
108
+ * class before mutating it.
109
+ */
69
110
  get(key: string): V | undefined;
111
+ /**
112
+ * The same lookup as {@link BlazeCache.get}, minus every side effect: no hit or miss is
113
+ * recorded, the entry is not marked used for eviction, and nothing is reclaimed.
114
+ *
115
+ * The read for "is this here?" questions — a UI check must not be able to move the hit
116
+ * rate or decide who gets evicted next. The value is still the cache's **live reference**,
117
+ * exactly like {@link BlazeCache.get}.
118
+ */
119
+ peek(key: string): V | undefined;
120
+ /**
121
+ * Milliseconds until `key` expires, or `undefined` when it has no TTL or is missing.
122
+ *
123
+ * The two `undefined`s mean different things: an entry with no deadline lives until it is
124
+ * evicted, a key that is not there at all will never be found again. Purely observational —
125
+ * statistics, eviction state and storage are all left alone.
126
+ */
127
+ ttl(key: string): number | undefined;
70
128
  /** `true` when `key` is present and not expired. Never changes eviction state. */
71
129
  has(key: string): boolean;
72
- /** Live entry — value, remaining TTL and tags — without touching statistics. */
130
+ /**
131
+ * Live entry — value, remaining TTL and tags — without touching statistics. The `value`
132
+ * field is the cache's live reference — see *Value ownership* on the class.
133
+ */
73
134
  entry(key: string): CacheEntry<V> | undefined;
74
- /** Snapshot of every live entry, oldest first. */
135
+ /**
136
+ * Snapshot of every live entry, oldest first. The `value` fields are the cache's live
137
+ * references — see *Value ownership* on the class.
138
+ */
75
139
  entries(): CacheEntry<V>[];
76
140
  /** Live keys, oldest first. */
77
141
  keys(): string[];
@@ -81,14 +145,33 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
81
145
  tagsOf(key: string): string[];
82
146
  /** `true` when `key` carries `tag`. */
83
147
  hasTag(key: string, tag: string): boolean;
84
- /** Number of stored entries (may include not-yet-pruned expired ones). */
85
- get size(): number;
86
- /** Maximum number of entries. */
87
- get capacity(): number;
148
+ /**
149
+ * Number of stored entries that are present **and** not expired.
150
+ *
151
+ * Expired-but-unpruned slots are skipped, so this always agrees with `keys()` and
152
+ * `entries()`. (`stats().size` is the raw count and may include them until `prune()`.)
153
+ */
154
+ size(): number;
155
+ /** Maximum number of entries — the `capacity` passed to {@link createCache}. */
156
+ capacity(): number;
88
157
  /** Cumulative counters plus a computed `hitRate`. */
89
158
  stats(): CacheStats;
90
- /** Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags. */
159
+ /**
160
+ * Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags.
161
+ *
162
+ * The value is stored **by reference** — the cache takes ownership for the lifetime of the
163
+ * entry, so mutating it afterwards rewrites the cache (see *Value ownership* on the class).
164
+ */
91
165
  set(key: string, value: V, options?: SetOptions): void;
166
+ /**
167
+ * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
168
+ * value is never changed.
169
+ *
170
+ * "Recently used" is SIEVE's visited bit, exactly what {@link BlazeCache.get} grants, so a
171
+ * touched entry survives the next eviction sweep. Returns `false` when the key is missing
172
+ * or expired: there is nothing to refresh, and an expired entry is never resurrected.
173
+ */
174
+ touch(key: string, options?: TouchOptions): boolean;
92
175
  /** Removes `key`, returning whether it was there. */
93
176
  delete(key: string): boolean;
94
177
  /** Removes every entry carrying any of `tags`, returning the removed keys. */
@@ -103,7 +186,9 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
103
186
  * Subscribes to mutations. Returns the unsubscribe function.
104
187
  *
105
188
  * Persistence uses this internally, so listeners fire for every change regardless of
106
- * whether storage is enabled.
189
+ * whether storage is enabled. A listener that throws is isolated: the failure is logged
190
+ * with `console.error`, the mutation it was told about stands, and the remaining listeners
191
+ * are still notified.
107
192
  */
108
193
  on(listener: CacheListener): () => void;
109
194
  /**
@@ -111,13 +196,20 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
111
196
  *
112
197
  * Resolves once the underlying transaction commits. Concurrent calls are serialised, so
113
198
  * this is safe to call from a `beforeunload` handler while a debounced flush is pending.
199
+ *
200
+ * When the write itself fails — quota, a blocked or transient IndexedDB error — the pass
201
+ * rejects **and hands every record it had claimed back onto the queue**, so the next flush
202
+ * (a later mutation's timer, an explicit call, `pagehide`, `dispose`) retries them instead
203
+ * of losing them.
114
204
  */
115
205
  flush(): Promise<void>;
116
206
  /**
117
207
  * Flushes, unbinds page-lifecycle listeners and frees the wasm memory.
118
208
  *
119
209
  * The cache is unusable afterwards. A failed flush still rejects — the caller may retry or
120
- * report it.
210
+ * report it — but teardown happens in a `finally`, so a storage outage can never leak the
211
+ * wasm instance, the timers or the `pagehide`/`visibilitychange` listeners behind a
212
+ * rejected promise.
121
213
  */
122
214
  dispose(): Promise<void>;
123
215
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,MAAM,wBAAwB,CAAC;AAElG,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAUxC,6DAA6D;AAC7D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,yFAAyF;IACzF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6FAA6F;IAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,+EAA+E;AAC/E,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,KAAK,GAAG,uBAAuB,GAAG,2BAA2B,CAAC;IAC5E;;;;;OAKG;IACH,IAA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AM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzC;;;;;OAKG;IACH,IAAI,IAAI,MAAM;IAId,gFAAgF;IAChF,QAAQ,IAAI,MAAM;IAIlB,qDAAqD;IACrD,KAAK,IAAI,UAAU;IAQnB;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAQtD;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO;IAQnD,qDAAqD;IACrD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAM5B,8EAA8E;IAC9E,cAAc,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAS3C,+DAA+D;IAC/D,KAAK,IAAI,MAAM,EAAE;IAQjB,yBAAyB;IACzB,KAAK,IAAI,IAAI;IAKb,sEAAsE;IACtE,UAAU,IAAI,IAAI;IAMlB;;;;;;;OAOG;IACH,EAAE,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAOvC;;;;;;;;;;OAUG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IActB;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CA2Q/B;AAED,+CAA+C;AAC/C,wBAAgB,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAExF"}
package/dist/cache.js CHANGED
@@ -23,10 +23,39 @@ const NO_TAGS = [];
23
23
  * const cache = await createCache({ capacity: 1000, persistence: { namespace: 'app' } });
24
24
  * cache.set('user:42', { name: 'Ada' }, { ttlMs: 30_000, tags: ['user:42'] });
25
25
  * cache.get('user:42'); // { name: 'Ada' } — counted as a hit
26
+ * cache.peek('user:42'); // the same value, no hit recorded
27
+ * cache.ttl('user:42'); // ~30000 — ms until it expires
28
+ * cache.touch('user:42', { ttlMs: 60_000 }); // renew the deadline, keep the value
26
29
  * cache.invalidateTags('user:42'); // removes it and syncs IndexedDB
27
30
  * await cache.dispose();
28
31
  * ```
29
32
  *
33
+ * ### Value ownership
34
+ *
35
+ * Values are held — and handed back — **by reference**. The object you pass to
36
+ * {@link BlazeCache.set} is the very object {@link BlazeCache.get}, {@link BlazeCache.peek},
37
+ * {@link BlazeCache.entry} and {@link BlazeCache.entries} return later: mutating either one
38
+ * silently rewrites the cache — and, after the next flush, the persisted row — with no error
39
+ * and no warning. Treat values living in the cache as read-only: clone on the way *out*
40
+ * (`structuredClone(cache.get(key))`) before editing, or clone on the way *in* if you want
41
+ * to keep mutating your own copy. The sharing is deliberate, not an oversight — the Rust
42
+ * core promises allocation-free `get`/`set` precisely *because* values are never cloned or
43
+ * serialised on the hot path, and cloning on read would only close one half of the alias
44
+ * anyway (your original reference from `set` survives either way). The contract is
45
+ * ownership transfer, not deep-copy semantics.
46
+ *
47
+ * ### Multiple tabs
48
+ *
49
+ * Tabs share one IndexedDB namespace but nothing else: each one holds its own WebAssembly
50
+ * instance, hydrated once at startup, and each flushes the keys it wrote. There is no
51
+ * coordination between them — writes are last-writer-wins per key. For ordinary use that is
52
+ * what you want (the tab in the foreground refetches on focus and rewrites its own fresh
53
+ * copy), but a tab that keeps working while hidden — a timer, a background sync — can flush
54
+ * a value older than the one the focused tab just wrote, and after a reload that older
55
+ * value is what hydration paints until revalidation corrects it. If that matters, use a
56
+ * short `ttlMs` on records written from background tabs, or filter on a timestamp you store
57
+ * inside the value itself.
58
+ *
30
59
  * All reads and writes are synchronous — the wasm module is instantiated during `create`, so
31
60
  * the hot path never touches a `Promise`.
32
61
  */
@@ -59,19 +88,51 @@ export class BlazeCache {
59
88
  return cache;
60
89
  }
61
90
  // ------------------------------------------------------------------ reads
62
- /** Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss. */
91
+ /**
92
+ * Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss.
93
+ *
94
+ * The value comes back as the cache's **live reference** — see *Value ownership* on the
95
+ * class before mutating it.
96
+ */
63
97
  get(key) {
64
98
  return this.#wasm.get(key);
65
99
  }
100
+ /**
101
+ * The same lookup as {@link BlazeCache.get}, minus every side effect: no hit or miss is
102
+ * recorded, the entry is not marked used for eviction, and nothing is reclaimed.
103
+ *
104
+ * The read for "is this here?" questions — a UI check must not be able to move the hit
105
+ * rate or decide who gets evicted next. The value is still the cache's **live reference**,
106
+ * exactly like {@link BlazeCache.get}.
107
+ */
108
+ peek(key) {
109
+ return this.#wasm.peek(key);
110
+ }
111
+ /**
112
+ * Milliseconds until `key` expires, or `undefined` when it has no TTL or is missing.
113
+ *
114
+ * The two `undefined`s mean different things: an entry with no deadline lives until it is
115
+ * evicted, a key that is not there at all will never be found again. Purely observational —
116
+ * statistics, eviction state and storage are all left alone.
117
+ */
118
+ ttl(key) {
119
+ return this.#wasm.ttl(key);
120
+ }
66
121
  /** `true` when `key` is present and not expired. Never changes eviction state. */
67
122
  has(key) {
68
123
  return this.#wasm.has(key);
69
124
  }
70
- /** Live entry — value, remaining TTL and tags — without touching statistics. */
125
+ /**
126
+ * Live entry — value, remaining TTL and tags — without touching statistics. The `value`
127
+ * field is the cache's live reference — see *Value ownership* on the class.
128
+ */
71
129
  entry(key) {
72
130
  return this.#wasm.entry(key);
73
131
  }
74
- /** Snapshot of every live entry, oldest first. */
132
+ /**
133
+ * Snapshot of every live entry, oldest first. The `value` fields are the cache's live
134
+ * references — see *Value ownership* on the class.
135
+ */
75
136
  entries() {
76
137
  return this.#wasm.entries();
77
138
  }
@@ -91,13 +152,18 @@ export class BlazeCache {
91
152
  hasTag(key, tag) {
92
153
  return this.#wasm.hasTag(key, tag);
93
154
  }
94
- /** Number of stored entries (may include not-yet-pruned expired ones). */
95
- get size() {
96
- return this.#wasm.size;
155
+ /**
156
+ * Number of stored entries that are present **and** not expired.
157
+ *
158
+ * Expired-but-unpruned slots are skipped, so this always agrees with `keys()` and
159
+ * `entries()`. (`stats().size` is the raw count and may include them until `prune()`.)
160
+ */
161
+ size() {
162
+ return this.#wasm.size();
97
163
  }
98
- /** Maximum number of entries. */
99
- get capacity() {
100
- return this.#wasm.capacity;
164
+ /** Maximum number of entries — the `capacity` passed to {@link createCache}. */
165
+ capacity() {
166
+ return this.#wasm.capacity();
101
167
  }
102
168
  /** Cumulative counters plus a computed `hitRate`. */
103
169
  stats() {
@@ -106,7 +172,12 @@ export class BlazeCache {
106
172
  return { ...base, hitRate: total === 0 ? 0 : base.hits / total };
107
173
  }
108
174
  // ----------------------------------------------------------------- writes
109
- /** Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags. */
175
+ /**
176
+ * Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags.
177
+ *
178
+ * The value is stored **by reference** — the cache takes ownership for the lifetime of the
179
+ * entry, so mutating it afterwards rewrites the cache (see *Value ownership* on the class).
180
+ */
110
181
  set(key, value, options) {
111
182
  // No defensive copy of `tags`: the binding reads the array synchronously while building
112
183
  // the wasm call and never retains it, so the `readonly`→`string[]` cast below is safe.
@@ -115,6 +186,22 @@ export class BlazeCache {
115
186
  if (this.#hasChangeConsumers)
116
187
  this.#notify({ type: 'set', key });
117
188
  }
189
+ /**
190
+ * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
191
+ * value is never changed.
192
+ *
193
+ * "Recently used" is SIEVE's visited bit, exactly what {@link BlazeCache.get} grants, so a
194
+ * touched entry survives the next eviction sweep. Returns `false` when the key is missing
195
+ * or expired: there is nothing to refresh, and an expired entry is never resurrected.
196
+ */
197
+ touch(key, options) {
198
+ const touched = this.#wasm.touch(key, options?.ttlMs ?? null);
199
+ // A renewed deadline is what storage would have to write back, so a touch is reported
200
+ // like any other write: listeners hear about it and the entry is marked dirty.
201
+ if (touched && this.#hasChangeConsumers)
202
+ this.#notify({ type: 'touch', key });
203
+ return touched;
204
+ }
118
205
  /** Removes `key`, returning whether it was there. */
119
206
  delete(key) {
120
207
  const removed = this.#wasm.delete(key);
@@ -155,7 +242,9 @@ export class BlazeCache {
155
242
  * Subscribes to mutations. Returns the unsubscribe function.
156
243
  *
157
244
  * Persistence uses this internally, so listeners fire for every change regardless of
158
- * whether storage is enabled.
245
+ * whether storage is enabled. A listener that throws is isolated: the failure is logged
246
+ * with `console.error`, the mutation it was told about stands, and the remaining listeners
247
+ * are still notified.
159
248
  */
160
249
  on(listener) {
161
250
  this.#listeners.add(listener);
@@ -168,6 +257,11 @@ export class BlazeCache {
168
257
  *
169
258
  * Resolves once the underlying transaction commits. Concurrent calls are serialised, so
170
259
  * this is safe to call from a `beforeunload` handler while a debounced flush is pending.
260
+ *
261
+ * When the write itself fails — quota, a blocked or transient IndexedDB error — the pass
262
+ * rejects **and hands every record it had claimed back onto the queue**, so the next flush
263
+ * (a later mutation's timer, an explicit call, `pagehide`, `dispose`) retries them instead
264
+ * of losing them.
171
265
  */
172
266
  flush() {
173
267
  if (this.#disposed)
@@ -184,23 +278,36 @@ export class BlazeCache {
184
278
  * Flushes, unbinds page-lifecycle listeners and frees the wasm memory.
185
279
  *
186
280
  * The cache is unusable afterwards. A failed flush still rejects — the caller may retry or
187
- * report it.
281
+ * report it — but teardown happens in a `finally`, so a storage outage can never leak the
282
+ * wasm instance, the timers or the `pagehide`/`visibilitychange` listeners behind a
283
+ * rejected promise.
188
284
  */
189
285
  async dispose() {
190
286
  if (this.#disposed)
191
287
  return;
192
- await this.flush();
193
- this.#disposed = true;
194
- if (this.#timer !== null) {
195
- clearTimeout(this.#timer);
196
- this.#timer = null;
288
+ try {
289
+ await this.flush();
290
+ }
291
+ finally {
292
+ this.#disposed = true;
293
+ if (this.#timer !== null) {
294
+ clearTimeout(this.#timer);
295
+ this.#timer = null;
296
+ }
297
+ for (const unbind of this.#unbind.splice(0))
298
+ unbind();
299
+ this.#listeners.clear();
300
+ try {
301
+ await this.#persist?.close?.();
302
+ }
303
+ catch (error) {
304
+ // Closing is best-effort (the IndexedDB adapter says as much): a failing adapter
305
+ // must neither break disposal nor mask the flush error this `finally` rethrows.
306
+ console.error('[blaze-cache] closing the persistence adapter failed.', error);
307
+ }
308
+ this.#persist = null;
309
+ this.#wasm.free();
197
310
  }
198
- for (const unbind of this.#unbind.splice(0))
199
- unbind();
200
- this.#listeners.clear();
201
- await this.#persist?.close?.();
202
- this.#persist = null;
203
- this.#wasm.free();
204
311
  }
205
312
  // ----------------------------------------------------------- persistence
206
313
  async #setupPersistence(spec) {
@@ -232,16 +339,55 @@ export class BlazeCache {
232
339
  }
233
340
  this.#bindPageLifecycle();
234
341
  }
235
- /** Fills the cache from storage, dropping records whose TTL elapsed while we were away. */
342
+ /**
343
+ * Fills the cache from storage, dropping records whose TTL elapsed while we were away —
344
+ * and records no well-formed write could ever have produced.
345
+ *
346
+ * `load()` hands back whatever sits on disk: an older package version, another tab or a
347
+ * flaky adapter may have left a row that no longer matches {@link PersistedRecord} — a
348
+ * missing key, `tags` that are not an array, a deadline that is not a number. One such row
349
+ * must cost exactly that row: every record is shape-checked (and its wasm `set` guarded)
350
+ * individually, so the remaining records still hydrate. The complaint is a single
351
+ * `console.warn` per run, not one per bad row.
352
+ */
236
353
  async #hydrate(adapter) {
237
354
  const records = await adapter.load();
238
355
  const now = Date.now();
356
+ let reported = false;
357
+ const skip = (reason, record, error) => {
358
+ if (reported)
359
+ return;
360
+ reported = true;
361
+ console.warn(`[blaze-cache] skipping malformed persisted record — ${reason}.`, record, ...(error === undefined ? [] : [error]));
362
+ };
239
363
  for (const record of records) {
240
- const remaining = record.ttlMs === null ? null : record.ttlMs - (now - record.storedAt);
241
- if (remaining !== null && remaining <= 0)
364
+ let reason = null;
365
+ if (typeof record?.key !== 'string') {
366
+ reason = 'key is missing or not a string';
367
+ }
368
+ else if (!Array.isArray(record.tags) || record.tags.some((tag) => typeof tag !== 'string')) {
369
+ reason = 'tags are not an array of strings';
370
+ }
371
+ else if (record.ttlMs !== null &&
372
+ (!Number.isFinite(record.ttlMs) || !Number.isFinite(record.storedAt))) {
373
+ // With a TTL present, both halves of the deadline must be real numbers — anything
374
+ // else yields a `NaN` that would masquerade as "never expires".
375
+ reason = 'ttl or storedAt is not a finite number';
376
+ }
377
+ if (reason !== null) {
378
+ skip(reason, record);
242
379
  continue;
243
- // Direct wasm call: hydration is not a user write, so it emits no change event.
244
- this.#wasm.set(record.key, record.value, remaining, record.tags);
380
+ }
381
+ try {
382
+ const remaining = record.ttlMs === null ? null : record.ttlMs - (now - record.storedAt);
383
+ if (remaining !== null && remaining <= 0)
384
+ continue;
385
+ // Direct wasm call: hydration is not a user write, so it emits no change event.
386
+ this.#wasm.set(record.key, record.value, remaining, record.tags);
387
+ }
388
+ catch (error) {
389
+ skip('the wasm core refused the write', record, error);
390
+ }
245
391
  }
246
392
  }
247
393
  #bindPageLifecycle() {
@@ -278,34 +424,82 @@ export class BlazeCache {
278
424
  if (!persist || this.#disposed)
279
425
  return;
280
426
  // Take ownership of the pending work up front, so a `set` racing with the awaits below
281
- // lands in the *next* pass instead of being written twice.
427
+ // lands in the *next* pass instead of being written twice. The claimed records stay in
428
+ // these locals for the whole pass: if the adapter rejects — quota, a transient
429
+ // IndexedDB failure — the catch below hands every one of them back to the queues, so a
430
+ // failed flush delays work rather than destroying it. Single-flight still holds: this
431
+ // run is chained on `#chain`, and the next `flush()` chains onto *our* settled promise,
432
+ // requeued work included.
282
433
  const clearAll = this.#clearAll;
283
434
  const deleted = [...this.#deleted];
284
435
  const dirty = [...this.#dirty].filter((key) => !this.#deleted.has(key));
285
436
  this.#clearAll = false;
286
437
  this.#dirty.clear();
287
438
  this.#deleted.clear();
288
- if (clearAll)
289
- await persist.clear();
290
- if (dirty.length > 0) {
291
- const records = [];
292
- for (const key of dirty.slice(-this.#maxRecords)) {
293
- const entry = this.#wasm.entry(key);
294
- if (!entry)
295
- continue;
296
- records.push({
297
- key,
298
- value: entry.value,
299
- tags: entry.tags,
300
- ttlMs: entry.ttlMs,
301
- storedAt: Date.now(),
302
- });
439
+ let toRemove = deleted;
440
+ try {
441
+ if (clearAll)
442
+ await persist.clear();
443
+ if (dirty.length > 0) {
444
+ const records = [];
445
+ for (const key of dirty.slice(-this.#maxRecords)) {
446
+ const entry = this.#wasm.entry(key);
447
+ if (!entry)
448
+ continue;
449
+ records.push({
450
+ key,
451
+ value: entry.value,
452
+ tags: entry.tags,
453
+ ttlMs: entry.ttlMs,
454
+ storedAt: Date.now(),
455
+ });
456
+ }
457
+ if (records.length > 0)
458
+ await persist.save(records);
459
+ }
460
+ // Reconcile the rows the wasm core dropped on its own. A capacity eviction inside
461
+ // `set` and a lapsed TTL never emit a change event — nothing queued a delete for them
462
+ // — so without this diff their rows would outlive every flush, be re-hydrated at the
463
+ // next startup, and eat quota until a `QuotaExceededError` kills persistence outright.
464
+ // Any key storage still holds that the wasm core no longer lists is stale. Skipped
465
+ // after `clear()` (storage was just emptied) and for adapters without `keys()`.
466
+ if (!clearAll && typeof persist.keys === 'function') {
467
+ const persisted = await persist.keys();
468
+ // Read the live set *after* the await, so a `set` landing mid-pass counts as live
469
+ // and keeps its row — and nothing awaits before `remove`, so the diff cannot go
470
+ // stale under our feet.
471
+ const live = new Set(this.#wasm.keys());
472
+ const stale = persisted.filter((key) => !live.has(key));
473
+ if (stale.length > 0)
474
+ toRemove = [...new Set([...deleted, ...stale])];
303
475
  }
304
- if (records.length > 0)
305
- await persist.save(records);
476
+ // One last synchronous guard: a key re-`set` while the pass was awaiting belongs to
477
+ // the *next* pass's `save`, so removing its row here would only open a window where
478
+ // memory and storage disagree.
479
+ const targets = toRemove.filter((key) => !this.#dirty.has(key));
480
+ if (targets.length > 0)
481
+ await persist.remove(targets);
482
+ }
483
+ catch (error) {
484
+ // Hand back exactly what this pass claimed. Concurrent work that landed during the
485
+ // awaits is kept as-is, and the two queues stay disjoint — a key the runner may have
486
+ // touched in the meantime belongs to whoever claimed it last.
487
+ if (clearAll)
488
+ this.#clearAll = true;
489
+ for (const key of dirty) {
490
+ // Deleted while we were awaiting? Its delete bookkeeping is already queued — don't
491
+ // resurrect it on the dirty side.
492
+ if (!this.#deleted.has(key))
493
+ this.#dirty.add(key);
494
+ }
495
+ for (const key of toRemove) {
496
+ // Re-`set` while we were awaiting? Then the next pass must save it, not delete the
497
+ // row that save would write.
498
+ if (!this.#dirty.has(key))
499
+ this.#deleted.add(key);
500
+ }
501
+ throw error;
306
502
  }
307
- if (deleted.length > 0)
308
- await persist.remove(deleted);
309
503
  }
310
504
  /**
311
505
  * `true` when a change event would actually reach someone — persistence bookkeeping or at
@@ -323,6 +517,7 @@ export class BlazeCache {
323
517
  if (this.#persist && !this.#disposed) {
324
518
  switch (change.type) {
325
519
  case 'set':
520
+ case 'touch':
326
521
  this.#deleted.delete(change.key);
327
522
  this.#dirty.add(change.key);
328
523
  break;
@@ -345,8 +540,16 @@ export class BlazeCache {
345
540
  }
346
541
  this.#scheduleFlush();
347
542
  }
348
- for (const listener of this.#listeners)
349
- listener(change);
543
+ for (const listener of this.#listeners) {
544
+ try {
545
+ listener(change);
546
+ }
547
+ catch (error) {
548
+ // The mutation already happened and the bookkeeping above already ran — a bad
549
+ // subscriber must not abort its siblings or surface out of a successful `set`.
550
+ console.error('[blaze-cache] change listener failed — the remaining listeners still run.', error);
551
+ }
552
+ }
350
553
  }
351
554
  }
352
555
  /** Shorthand for {@link BlazeCache.create}. */
package/dist/cache.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE,iDAAiD;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,wDAAw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AE,CAAC;YACvC,IAAI,CAAC;gBACH,QAAQ,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,8EAA8E;gBAC9E,+EAA+E;gBAC/E,OAAO,CAAC,KAAK,CAAC,2EAA2E,EAAE,KAAK,CAAC,CAAC;YACpG,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,+CAA+C;AAC/C,MAAM,UAAU,WAAW,CAAU,OAA2B;IAC9D,OAAO,UAAU,CAAC,MAAM,CAAI,OAAO,CAAC,CAAC;AACvC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -21,5 +21,5 @@ export type { WasmInitInput } from './wasm.js';
21
21
  export { indexedDbPersistence } from './persistence/indexeddb.js';
22
22
  export type { CachePersistence, IndexedDbOptions, PersistedRecord } from './persistence/types.js';
23
23
  export { safeStableStringify, stableStringify } from './utils.js';
24
- export type { BlazeCacheLike, CacheChange, CacheEntry, CacheListener, CacheStats, SetOptions, } from './types.js';
24
+ export type { BlazeCacheLike, CacheChange, CacheEntry, CacheListener, CacheStats, SetOptions, TouchOptions, } from './types.js';
25
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACpH,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE1G,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAElG,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,YAAY,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACpH,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE1G,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAElG,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,YAAY,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../src/persistence/indexeddb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,MAAM,YAAY,CAAC;AAatF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAsIrF"}
1
+ {"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../src/persistence/indexeddb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,MAAM,YAAY,CAAC;AAatF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAyJrF"}
@@ -39,6 +39,16 @@ export function indexedDbPersistence(options = {}) {
39
39
  };
40
40
  request.onsuccess = () => {
41
41
  const db = request.result;
42
+ // Another tab can bump the database version at any moment; without a handler our
43
+ // connection would block their `versionchange` event forever. Closing here keeps
44
+ // the world coherent: `opening` only ever promises a *usable* connection, so the
45
+ // next `open()` re-establishes one instead of handing out this closed zombie.
46
+ const settled = opening;
47
+ db.onversionchange = () => {
48
+ db.close();
49
+ if (opening === settled)
50
+ opening = null;
51
+ };
42
52
  if (db.objectStoreNames.contains(store)) {
43
53
  resolve(db);
44
54
  return;
@@ -128,6 +138,15 @@ export function indexedDbPersistence(options = {}) {
128
138
  objectStore.delete(key);
129
139
  });
130
140
  },
141
+ async keys() {
142
+ const db = await open();
143
+ const ids = await indexKeys(db);
144
+ const prefix = `${namespace}\u0000`;
145
+ // The index hands back composite ids; strip the prefix to recover the cache keys, and
146
+ // ignore anything that somehow lacks it rather than feeding nonsense to reconciliation.
147
+ return ids.filter((id) => typeof id === 'string' && id.startsWith(prefix))
148
+ .map((id) => id.slice(prefix.length));
149
+ },
131
150
  async close() {
132
151
  if (!opening)
133
152
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"indexeddb.js","sourceRoot":"","sources":["../../src/persistence/indexeddb.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAG,aAAa,CAAC;AACvC,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AACpC,MAAM,UAAU,GAAG,CAAC,CAAC;AAQrB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAA4B,EAAE;IACjE,MAAM,QAAQ,GAAG,OAAO,CAA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;YACT,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,uEAAuE;YACvE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YAC3C,OAAO,GAAG,IAAI,CAAC;YACf,EAAE,EAAE,KAAK,EAAE,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -28,6 +28,18 @@ export interface CachePersistence {
28
28
  remove(keys: string[]): Promise<void>;
29
29
  /** Deletes every record belonging to this cache (other namespaces are left alone). */
30
30
  clear(): Promise<void>;
31
+ /**
32
+ * Every record key currently stored for this cache's namespace.
33
+ *
34
+ * Optional, and only needed for reconciliation: the wasm core drops entries on its own —
35
+ * a capacity eviction or a lapsed TTL never produces a change event — so those rows would
36
+ * otherwise sit in storage until quota runs out. A flush compares this list against the
37
+ * live keys and calls {@link CachePersistence.remove} for the difference.
38
+ *
39
+ * Adapters that do not implement it keep working exactly as before; they simply skip the
40
+ * diff, and any explicit `delete`/`invalidateTags`/`prune` still reaches `remove`.
41
+ */
42
+ keys?(): Promise<string[]>;
31
43
  /** Releases any underlying handle. */
32
44
  close?(): void | Promise<void>;
33
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/persistence/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,mFAAmF;IACnF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kFAAkF;IAClF,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACnC,yDAAyD;IACzD,IAAI,CA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H,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3B,sCAAsC;IACtC,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
package/dist/types.d.ts CHANGED
@@ -13,6 +13,19 @@ export interface SetOptions {
13
13
  /** Tag names, used for bulk removal through `invalidateTags`. */
14
14
  tags?: readonly string[];
15
15
  }
16
+ /**
17
+ * Options applied to a single {@link BlazeCache.touch}.
18
+ */
19
+ export interface TouchOptions {
20
+ /**
21
+ * Milliseconds until the entry expires, counted **from this moment**.
22
+ *
23
+ * Omit it (or pass `undefined`) to leave the existing deadline exactly as it is. `0`,
24
+ * negatives and `NaN` drop the deadline altogether — the entry then lives until evicted,
25
+ * which is how {@link SetOptions.ttlMs} reads those same values.
26
+ */
27
+ ttlMs?: number;
28
+ }
16
29
  /**
17
30
  * A snapshot of the cache's counters.
18
31
  *
@@ -47,6 +60,9 @@ export interface CacheEntry<V = unknown> {
47
60
  export type CacheChange = {
48
61
  type: 'set';
49
62
  key: string;
63
+ } | {
64
+ type: 'touch';
65
+ key: string;
50
66
  } | {
51
67
  type: 'delete';
52
68
  key: string;
@@ -76,6 +92,7 @@ export interface BlazeCacheLike<V = any> {
76
92
  set(key: string, value: V, options?: SetOptions): void;
77
93
  has(key: string): boolean;
78
94
  delete(key: string): boolean;
79
- readonly size: number;
95
+ /** Number of entries that are present **and** not expired. */
96
+ size(): number;
80
97
  }
81
98
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GA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E,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEtC,2DAA2D;AAC3D,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;AAE1D;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACvD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,8DAA8D;IAC9D,IAAI,IAAI,MAAM,CAAC;CAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgBtD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMtE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA0BtD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMtE"}
package/dist/utils.js CHANGED
@@ -22,7 +22,17 @@ export function stableStringify(value) {
22
22
  const source = raw;
23
23
  const sorted = {};
24
24
  for (const key of Object.keys(source).sort()) {
25
- sorted[key] = source[key];
25
+ // Plain `sorted[key] = …` would *not* create an own property for a literal `__proto__`
26
+ // key: the inherited setter would swap `sorted`'s prototype instead, dropping the key
27
+ // from the output and mutating the fresh object we just allocated. `defineProperty`
28
+ // always defines an own data property, so hostile keys serialise normally — and only
29
+ // ever inside this throwaway `sorted`, never on `Object.prototype`.
30
+ Object.defineProperty(sorted, key, {
31
+ value: source[key],
32
+ enumerable: true,
33
+ writable: true,
34
+ configurable: true,
35
+ });
26
36
  }
27
37
  return sorted;
28
38
  });
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC;IAE5C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAY,EAAE,EAAE;QACxD,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;QAC9E,MAAM,MAAM,GAAG,GAA8B,CAAC;QAC9C,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAC7C,MAAM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QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,sFAAsF;IACtF,2DAA2D;IAC3D,OAAO,IAAI,IAAI,MAAM,CAAC;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cache/core",
3
- "version": "0.1.1",
3
+ "version": "0.2.1-beta",
4
4
  "description": "WebAssembly client-side cache for the browser: SIEVE eviction, per-entry TTLs, tag invalidation and optional IndexedDB persistence",
5
5
  "keywords": [
6
6
  "cache",
@@ -21,6 +21,7 @@
21
21
  "url": "git+https://github.com/blaze-cache/blaze-cache.git",
22
22
  "directory": "packages/core"
23
23
  },
24
+ "homepage": "https://blaze-cache.github.io/docs/",
24
25
  "publishConfig": {
25
26
  "access": "public"
26
27
  },
@@ -50,6 +51,7 @@
50
51
  },
51
52
  "scripts": {
52
53
  "build": "tsc -p tsconfig.json",
54
+ "test": "pnpm run build && node --test",
53
55
  "typecheck": "tsc -p tsconfig.json --noEmit"
54
56
  }
55
57
  }
@@ -7,6 +7,10 @@
7
7
  export class BlazeCache {
8
8
  free(): void;
9
9
  [Symbol.dispose](): void;
10
+ /**
11
+ * Maximum number of entries — the `capacity` passed to `createCache`.
12
+ */
13
+ capacity(): number;
10
14
  /**
11
15
  * Empties the cache.
12
16
  */
@@ -55,9 +59,28 @@ export class BlazeCache {
55
59
  */
56
60
  keys(): string[];
57
61
  /**
58
- * Creates a cache that holds at most `capacity` entries (clamped to `>= 1`).
62
+ * Creates a cache that holds at most `capacity` entries.
63
+ *
64
+ * `capacity` arrives as a JS `Number`, so it is validated before anything else sees it:
65
+ *
66
+ * * non-finite (`NaN`, `Infinity`) — meaningless as a size, falls back to the default;
67
+ * * below `1` — clamped up to `1`, exactly as the core clamps `0`; note this also
68
+ * covers negatives, which JS→integer conversion would otherwise deliver as ~4.29e9;
69
+ * * above [`MAX_CAPACITY`] — clamped down, because `capacity()` reports it back and
70
+ * nobody builds a browser cache meant to hold a billion entries.
71
+ *
72
+ * The core also caps its own index reservation, so even an unvalidated number could no
73
+ * longer abort the instance with a huge up-front allocation.
59
74
  */
60
75
  constructor(capacity: number);
76
+ /**
77
+ * Same lookup as [`get`](Self::get) — **without** recording a hit or a miss, and without
78
+ * marking the entry visited for SIEVE.
79
+ *
80
+ * The read for "is this here?" questions: it leaves the hit rate and the eviction order
81
+ * exactly as it found them, and it never reclaims an expired entry.
82
+ */
83
+ peek(key: string): any | undefined;
61
84
  /**
62
85
  * Removes every expired entry, returning the removed keys.
63
86
  */
@@ -78,6 +101,13 @@ export class BlazeCache {
78
101
  * can never evict itself.
79
102
  */
80
103
  set(key: string, value: any, ttl_ms: number | null | undefined, tags: string[]): void;
104
+ /**
105
+ * Number of stored entries that are present **and** not expired — expired-but-unpruned
106
+ * slots are not counted, so this always matches what `keys()`/`entries()` return.
107
+ *
108
+ * `O(1)` when no entry carries a TTL, otherwise a single oldest-first walk.
109
+ */
110
+ size(): number;
81
111
  /**
82
112
  * Counters: `{ hits, misses, evictions, expirations, invalidations, size, capacity }`.
83
113
  */
@@ -87,13 +117,19 @@ export class BlazeCache {
87
117
  */
88
118
  tagsOf(key: string): string[];
89
119
  /**
90
- * Maximum number of entries.
120
+ * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
121
+ * value is never changed. Returns `false` when the key is missing or expired.
122
+ *
123
+ * * `ttlMs` — `undefined`/`null` leaves the current deadline alone; a positive finite
124
+ * number replaces it with "now + ttlMs"; `0`, negatives and `NaN` drop the deadline
125
+ * (never expires), the same reading [`set`](Self::set) gives them.
91
126
  */
92
- readonly capacity: number;
127
+ touch(key: string, ttl_ms?: number | null): boolean;
93
128
  /**
94
- * Current number of stored entries (may include not-yet-pruned expired ones).
129
+ * Milliseconds until `key` expires, or `undefined` when it carries no TTL or the key is
130
+ * missing/expired. Purely observational: statistics and eviction state are untouched.
95
131
  */
96
- readonly size: number;
132
+ ttl(key: string): number | undefined;
97
133
  }
98
134
 
99
135
  /**
@@ -119,12 +155,15 @@ export interface InitOutput {
119
155
  readonly blazecache_keys: (a: number, b: number) => void;
120
156
  readonly blazecache_keysWithTag: (a: number, b: number, c: number, d: number) => void;
121
157
  readonly blazecache_new: (a: number) => number;
158
+ readonly blazecache_peek: (a: number, b: number, c: number) => number;
122
159
  readonly blazecache_prune: (a: number, b: number) => void;
123
160
  readonly blazecache_resetStats: (a: number) => void;
124
161
  readonly blazecache_set: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
125
162
  readonly blazecache_size: (a: number) => number;
126
163
  readonly blazecache_stats: (a: number, b: number) => void;
127
164
  readonly blazecache_tagsOf: (a: number, b: number, c: number, d: number) => void;
165
+ readonly blazecache_touch: (a: number, b: number, c: number, d: number, e: number) => number;
166
+ readonly blazecache_ttl: (a: number, b: number, c: number, d: number) => void;
128
167
  readonly setPanicHook: () => void;
129
168
  readonly __wbindgen_export: (a: number, b: number) => number;
130
169
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
@@ -15,10 +15,10 @@ export class BlazeCache {
15
15
  wasm.__wbg_blazecache_free(ptr, 0);
16
16
  }
17
17
  /**
18
- * Maximum number of entries.
18
+ * Maximum number of entries — the `capacity` passed to `createCache`.
19
19
  * @returns {number}
20
20
  */
21
- get capacity() {
21
+ capacity() {
22
22
  const ret = wasm.blazecache_capacity(this.__wbg_ptr);
23
23
  return ret >>> 0;
24
24
  }
@@ -159,7 +159,18 @@ export class BlazeCache {
159
159
  }
160
160
  }
161
161
  /**
162
- * Creates a cache that holds at most `capacity` entries (clamped to `>= 1`).
162
+ * Creates a cache that holds at most `capacity` entries.
163
+ *
164
+ * `capacity` arrives as a JS `Number`, so it is validated before anything else sees it:
165
+ *
166
+ * * non-finite (`NaN`, `Infinity`) — meaningless as a size, falls back to the default;
167
+ * * below `1` — clamped up to `1`, exactly as the core clamps `0`; note this also
168
+ * covers negatives, which JS→integer conversion would otherwise deliver as ~4.29e9;
169
+ * * above [`MAX_CAPACITY`] — clamped down, because `capacity()` reports it back and
170
+ * nobody builds a browser cache meant to hold a billion entries.
171
+ *
172
+ * The core also caps its own index reservation, so even an unvalidated number could no
173
+ * longer abort the instance with a huge up-front allocation.
163
174
  * @param {number} capacity
164
175
  */
165
176
  constructor(capacity) {
@@ -168,6 +179,21 @@ export class BlazeCache {
168
179
  BlazeCacheFinalization.register(this, this.__wbg_ptr, this);
169
180
  return this;
170
181
  }
182
+ /**
183
+ * Same lookup as [`get`](Self::get) — **without** recording a hit or a miss, and without
184
+ * marking the entry visited for SIEVE.
185
+ *
186
+ * The read for "is this here?" questions: it leaves the hit rate and the eviction order
187
+ * exactly as it found them, and it never reclaims an expired entry.
188
+ * @param {string} key
189
+ * @returns {any | undefined}
190
+ */
191
+ peek(key) {
192
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
193
+ const len0 = WASM_VECTOR_LEN;
194
+ const ret = wasm.blazecache_peek(this.__wbg_ptr, ptr0, len0);
195
+ return takeObject(ret);
196
+ }
171
197
  /**
172
198
  * Removes every expired entry, returning the removed keys.
173
199
  * @returns {string[]}
@@ -214,10 +240,13 @@ export class BlazeCache {
214
240
  wasm.blazecache_set(this.__wbg_ptr, ptr0, len0, addHeapObject(value), !isLikeNone(ttl_ms), isLikeNone(ttl_ms) ? 0 : ttl_ms, ptr1, len1);
215
241
  }
216
242
  /**
217
- * Current number of stored entries (may include not-yet-pruned expired ones).
243
+ * Number of stored entries that are present **and** not expired — expired-but-unpruned
244
+ * slots are not counted, so this always matches what `keys()`/`entries()` return.
245
+ *
246
+ * `O(1)` when no entry carries a TTL, otherwise a single oldest-first walk.
218
247
  * @returns {number}
219
248
  */
220
- get size() {
249
+ size() {
221
250
  const ret = wasm.blazecache_size(this.__wbg_ptr);
222
251
  return ret >>> 0;
223
252
  }
@@ -260,6 +289,42 @@ export class BlazeCache {
260
289
  wasm.__wbindgen_add_to_stack_pointer(16);
261
290
  }
262
291
  }
292
+ /**
293
+ * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
294
+ * value is never changed. Returns `false` when the key is missing or expired.
295
+ *
296
+ * * `ttlMs` — `undefined`/`null` leaves the current deadline alone; a positive finite
297
+ * number replaces it with "now + ttlMs"; `0`, negatives and `NaN` drop the deadline
298
+ * (never expires), the same reading [`set`](Self::set) gives them.
299
+ * @param {string} key
300
+ * @param {number | null} [ttl_ms]
301
+ * @returns {boolean}
302
+ */
303
+ touch(key, ttl_ms) {
304
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
305
+ const len0 = WASM_VECTOR_LEN;
306
+ const ret = wasm.blazecache_touch(this.__wbg_ptr, ptr0, len0, !isLikeNone(ttl_ms), isLikeNone(ttl_ms) ? 0 : ttl_ms);
307
+ return ret !== 0;
308
+ }
309
+ /**
310
+ * Milliseconds until `key` expires, or `undefined` when it carries no TTL or the key is
311
+ * missing/expired. Purely observational: statistics and eviction state are untouched.
312
+ * @param {string} key
313
+ * @returns {number | undefined}
314
+ */
315
+ ttl(key) {
316
+ try {
317
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
318
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
319
+ const len0 = WASM_VECTOR_LEN;
320
+ wasm.blazecache_ttl(retptr, this.__wbg_ptr, ptr0, len0);
321
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
322
+ var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true);
323
+ return r0 === 0 ? undefined : r2;
324
+ } finally {
325
+ wasm.__wbindgen_add_to_stack_pointer(16);
326
+ }
327
+ }
263
328
  }
264
329
  if (Symbol.dispose) BlazeCache.prototype[Symbol.dispose] = BlazeCache.prototype.free;
265
330
 
Binary file
@@ -14,12 +14,15 @@ export const blazecache_invalidateTags: (a: number, b: number, c: number, d: num
14
14
  export const blazecache_keys: (a: number, b: number) => void;
15
15
  export const blazecache_keysWithTag: (a: number, b: number, c: number, d: number) => void;
16
16
  export const blazecache_new: (a: number) => number;
17
+ export const blazecache_peek: (a: number, b: number, c: number) => number;
17
18
  export const blazecache_prune: (a: number, b: number) => void;
18
19
  export const blazecache_resetStats: (a: number) => void;
19
20
  export const blazecache_set: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
20
21
  export const blazecache_size: (a: number) => number;
21
22
  export const blazecache_stats: (a: number, b: number) => void;
22
23
  export const blazecache_tagsOf: (a: number, b: number, c: number, d: number) => void;
24
+ export const blazecache_touch: (a: number, b: number, c: number, d: number, e: number) => number;
25
+ export const blazecache_ttl: (a: number, b: number, c: number, d: number) => void;
23
26
  export const setPanicHook: () => void;
24
27
  export const __wbindgen_export: (a: number, b: number) => number;
25
28
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;