@blaze-cache/core 0.1.0 → 0.2.0-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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Blaze Cache
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/blaze-cache/blaze-cache/main/docs/blaze-cache-logo.png" alt="Blaze Cache logo" width="150">
3
+ </p>
4
+
5
+ <h1 align="center">@blaze-cache/core</h1>
6
+
7
+ WebAssembly client-side cache for the browser: SIEVE eviction, per-entry TTLs, tag
8
+ invalidation and optional IndexedDB persistence.
9
+
10
+ The engine behind
11
+ [`@blaze-cache/axios`](https://www.npmjs.com/package/@blaze-cache/axios) and
12
+ [`@blaze-cache/react-query`](https://www.npmjs.com/package/@blaze-cache/react-query) —
13
+ also usable on its own.
14
+
15
+ ## Install
16
+
17
+ ```sh
18
+ npm install @blaze-cache/core
19
+ ```
20
+
21
+ ## Quick start
22
+
23
+ ```ts
24
+ import { createCache } from '@blaze-cache/core';
25
+
26
+ const cache = await createCache({ capacity: 1000, persistence: { namespace: 'app' } });
27
+
28
+ cache.set('user:42', { name: 'Ada' }, { ttlMs: 30_000, tags: ['user:42'] });
29
+
30
+ cache.get('user:42'); // { name: 'Ada' } — counted as a hit
31
+ cache.peek('user:42'); // the same value, with no hit recorded
32
+ cache.ttl('user:42'); // ~30000 — ms until it expires
33
+ cache.touch('user:42', { ttlMs: 60_000 }); // renew the deadline, keep the value
34
+ cache.invalidateTags('user:42'); // removes it, synchronously, and syncs IndexedDB
35
+ cache.stats(); // { hits, misses, evictions, expirations, … }
36
+ ```
37
+
38
+ `create` instantiates the wasm module once, so everything after it is **synchronous** —
39
+ `get`/`set` never allocate a `Promise`.
40
+
41
+ ## Good to know
42
+
43
+ * **The `.wasm` ships inside this package** — no CDN setup. If your bundler
44
+ pre-bundles dependencies, point at it explicitly:
45
+
46
+ ```ts
47
+ import wasmUrl from '@blaze-cache/core/pkg/blaze_cache_wasm_bg.wasm?url';
48
+
49
+ const cache = await createCache({ wasm: wasmUrl });
50
+ ```
51
+
52
+ * **Types are bundled** — no `@types/*` packages to install.
53
+ * **ESM only, browser only.** Node/SSR targets are out of scope by design.
54
+ * **Persistence is optional** and off by default; a blocked IndexedDB (private mode)
55
+ degrades to memory-only instead of breaking the app.
56
+
57
+ ## Documentation
58
+
59
+ Setup, persistence, eviction, tags and the full API are documented in the
60
+ [repository README](https://github.com/blaze-cache/blaze-cache#readme).
61
+
62
+ ## License
63
+
64
+ [MIT](https://github.com/blaze-cache/blaze-cache/blob/main/LICENSE) © Blaze Cache
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. */
@@ -48,6 +48,9 @@ export interface BlazeCacheOptions {
48
48
  * const cache = await createCache({ capacity: 1000, persistence: { namespace: 'app' } });
49
49
  * cache.set('user:42', { name: 'Ada' }, { ttlMs: 30_000, tags: ['user:42'] });
50
50
  * cache.get('user:42'); // { name: 'Ada' } — counted as a hit
51
+ * cache.peek('user:42'); // the same value, no hit recorded
52
+ * cache.ttl('user:42'); // ~30000 — ms until it expires
53
+ * cache.touch('user:42', { ttlMs: 60_000 }); // renew the deadline, keep the value
51
54
  * cache.invalidateTags('user:42'); // removes it and syncs IndexedDB
52
55
  * await cache.dispose();
53
56
  * ```
@@ -67,6 +70,22 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
67
70
  static create<V = any>(options?: BlazeCacheOptions): Promise<BlazeCache<V>>;
68
71
  /** Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss. */
69
72
  get(key: string): V | undefined;
73
+ /**
74
+ * The same lookup as {@link BlazeCache.get}, minus every side effect: no hit or miss is
75
+ * recorded, the entry is not marked used for eviction, and nothing is reclaimed.
76
+ *
77
+ * The read for "is this here?" questions — a UI check must not be able to move the hit
78
+ * rate or decide who gets evicted next.
79
+ */
80
+ peek(key: string): V | undefined;
81
+ /**
82
+ * Milliseconds until `key` expires, or `undefined` when it has no TTL or is missing.
83
+ *
84
+ * The two `undefined`s mean different things: an entry with no deadline lives until it is
85
+ * evicted, a key that is not there at all will never be found again. Purely observational —
86
+ * statistics, eviction state and storage are all left alone.
87
+ */
88
+ ttl(key: string): number | undefined;
70
89
  /** `true` when `key` is present and not expired. Never changes eviction state. */
71
90
  has(key: string): boolean;
72
91
  /** Live entry — value, remaining TTL and tags — without touching statistics. */
@@ -81,14 +100,28 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
81
100
  tagsOf(key: string): string[];
82
101
  /** `true` when `key` carries `tag`. */
83
102
  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;
103
+ /**
104
+ * Number of stored entries that are present **and** not expired.
105
+ *
106
+ * Expired-but-unpruned slots are skipped, so this always agrees with `keys()` and
107
+ * `entries()`. (`stats().size` is the raw count and may include them until `prune()`.)
108
+ */
109
+ size(): number;
110
+ /** Maximum number of entries — the `capacity` passed to {@link createCache}. */
111
+ capacity(): number;
88
112
  /** Cumulative counters plus a computed `hitRate`. */
89
113
  stats(): CacheStats;
90
114
  /** Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags. */
91
115
  set(key: string, value: V, options?: SetOptions): void;
116
+ /**
117
+ * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
118
+ * value is never changed.
119
+ *
120
+ * "Recently used" is SIEVE's visited bit, exactly what {@link BlazeCache.get} grants, so a
121
+ * touched entry survives the next eviction sweep. Returns `false` when the key is missing
122
+ * or expired: there is nothing to refresh, and an expired entry is never resurrected.
123
+ */
124
+ touch(key: string, options?: TouchOptions): boolean;
92
125
  /** Removes `key`, returning whether it was there. */
93
126
  delete(key: string): boolean;
94
127
  /** Removes every entry carrying any of `tags`, returning the removed keys. */
@@ -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;AA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U,IAAI,IAAI;IAMlB;;;;;OAKG;IACH,EAAE,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAOvC;;;;;OAKG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IActB;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAmK/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
@@ -6,6 +6,14 @@ export const DEFAULT_CAPACITY = 500;
6
6
  export const DEFAULT_FLUSH_DELAY_MS = 400;
7
7
  /** Upper bound on records written by a single flush. */
8
8
  export const DEFAULT_MAX_RECORDS = 2000;
9
+ /**
10
+ * Shared stand-in for "no tags" on the write path.
11
+ *
12
+ * The binding copies the array into wasm memory synchronously during the call and never
13
+ * retains it, so one module-level array can serve every untagged write instead of allocating
14
+ * a fresh `[]` per `set`. Never mutated.
15
+ */
16
+ const NO_TAGS = [];
9
17
  /**
10
18
  * The client-side cache: WebAssembly storage and eviction, optional write-through persistence.
11
19
  *
@@ -15,6 +23,9 @@ export const DEFAULT_MAX_RECORDS = 2000;
15
23
  * const cache = await createCache({ capacity: 1000, persistence: { namespace: 'app' } });
16
24
  * cache.set('user:42', { name: 'Ada' }, { ttlMs: 30_000, tags: ['user:42'] });
17
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
18
29
  * cache.invalidateTags('user:42'); // removes it and syncs IndexedDB
19
30
  * await cache.dispose();
20
31
  * ```
@@ -55,6 +66,26 @@ export class BlazeCache {
55
66
  get(key) {
56
67
  return this.#wasm.get(key);
57
68
  }
69
+ /**
70
+ * The same lookup as {@link BlazeCache.get}, minus every side effect: no hit or miss is
71
+ * recorded, the entry is not marked used for eviction, and nothing is reclaimed.
72
+ *
73
+ * The read for "is this here?" questions — a UI check must not be able to move the hit
74
+ * rate or decide who gets evicted next.
75
+ */
76
+ peek(key) {
77
+ return this.#wasm.peek(key);
78
+ }
79
+ /**
80
+ * Milliseconds until `key` expires, or `undefined` when it has no TTL or is missing.
81
+ *
82
+ * The two `undefined`s mean different things: an entry with no deadline lives until it is
83
+ * evicted, a key that is not there at all will never be found again. Purely observational —
84
+ * statistics, eviction state and storage are all left alone.
85
+ */
86
+ ttl(key) {
87
+ return this.#wasm.ttl(key);
88
+ }
58
89
  /** `true` when `key` is present and not expired. Never changes eviction state. */
59
90
  has(key) {
60
91
  return this.#wasm.has(key);
@@ -83,13 +114,18 @@ export class BlazeCache {
83
114
  hasTag(key, tag) {
84
115
  return this.#wasm.hasTag(key, tag);
85
116
  }
86
- /** Number of stored entries (may include not-yet-pruned expired ones). */
87
- get size() {
88
- return this.#wasm.size;
117
+ /**
118
+ * Number of stored entries that are present **and** not expired.
119
+ *
120
+ * Expired-but-unpruned slots are skipped, so this always agrees with `keys()` and
121
+ * `entries()`. (`stats().size` is the raw count and may include them until `prune()`.)
122
+ */
123
+ size() {
124
+ return this.#wasm.size();
89
125
  }
90
- /** Maximum number of entries. */
91
- get capacity() {
92
- return this.#wasm.capacity;
126
+ /** Maximum number of entries — the `capacity` passed to {@link createCache}. */
127
+ capacity() {
128
+ return this.#wasm.capacity();
93
129
  }
94
130
  /** Cumulative counters plus a computed `hitRate`. */
95
131
  stats() {
@@ -100,13 +136,33 @@ export class BlazeCache {
100
136
  // ----------------------------------------------------------------- writes
101
137
  /** Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags. */
102
138
  set(key, value, options) {
103
- this.#wasm.set(key, value, options?.ttlMs ?? null, options?.tags ? [...options.tags] : []);
104
- this.#notify({ type: 'set', key });
139
+ // No defensive copy of `tags`: the binding reads the array synchronously while building
140
+ // the wasm call and never retains it, so the `readonly`→`string[]` cast below is safe.
141
+ // Untagged writes share `NO_TAGS` (see its doc).
142
+ this.#wasm.set(key, value, options?.ttlMs ?? null, (options?.tags ?? NO_TAGS));
143
+ if (this.#hasChangeConsumers)
144
+ this.#notify({ type: 'set', key });
145
+ }
146
+ /**
147
+ * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
148
+ * value is never changed.
149
+ *
150
+ * "Recently used" is SIEVE's visited bit, exactly what {@link BlazeCache.get} grants, so a
151
+ * touched entry survives the next eviction sweep. Returns `false` when the key is missing
152
+ * or expired: there is nothing to refresh, and an expired entry is never resurrected.
153
+ */
154
+ touch(key, options) {
155
+ const touched = this.#wasm.touch(key, options?.ttlMs ?? null);
156
+ // A renewed deadline is what storage would have to write back, so a touch is reported
157
+ // like any other write: listeners hear about it and the entry is marked dirty.
158
+ if (touched && this.#hasChangeConsumers)
159
+ this.#notify({ type: 'touch', key });
160
+ return touched;
105
161
  }
106
162
  /** Removes `key`, returning whether it was there. */
107
163
  delete(key) {
108
164
  const removed = this.#wasm.delete(key);
109
- if (removed)
165
+ if (removed && this.#hasChangeConsumers)
110
166
  this.#notify({ type: 'delete', key });
111
167
  return removed;
112
168
  }
@@ -115,21 +171,24 @@ export class BlazeCache {
115
171
  if (tags.length === 0)
116
172
  return [];
117
173
  const removed = this.#wasm.invalidateTags(tags);
118
- if (removed.length > 0)
174
+ if (removed.length > 0 && this.#hasChangeConsumers) {
119
175
  this.#notify({ type: 'invalidate', keys: removed });
176
+ }
120
177
  return removed;
121
178
  }
122
179
  /** Removes every expired entry, returning the removed keys. */
123
180
  prune() {
124
181
  const removed = this.#wasm.prune();
125
- if (removed.length > 0)
182
+ if (removed.length > 0 && this.#hasChangeConsumers) {
126
183
  this.#notify({ type: 'prune', keys: removed });
184
+ }
127
185
  return removed;
128
186
  }
129
187
  /** Empties the cache. */
130
188
  clear() {
131
189
  this.#wasm.clear();
132
- this.#notify({ type: 'clear' });
190
+ if (this.#hasChangeConsumers)
191
+ this.#notify({ type: 'clear' });
133
192
  }
134
193
  /** Zeroes the cumulative counters without touching stored entries. */
135
194
  resetStats() {
@@ -292,10 +351,23 @@ export class BlazeCache {
292
351
  if (deleted.length > 0)
293
352
  await persist.remove(deleted);
294
353
  }
354
+ /**
355
+ * `true` when a change event would actually reach someone — persistence bookkeeping or at
356
+ * least one listener.
357
+ *
358
+ * Lets the mutation paths skip building a {@link CacheChange} object altogether when
359
+ * nothing consumes it (memory-only cache, no subscribers). Equivalent to the conditions
360
+ * inside {@link BlazeCache.#notify}: after `dispose` the persistence adapter is `null`, so
361
+ * the `!#disposed` check inside `#notify` cannot change the outcome here.
362
+ */
363
+ get #hasChangeConsumers() {
364
+ return this.#listeners.size > 0 || this.#persist !== null;
365
+ }
295
366
  #notify(change) {
296
367
  if (this.#persist && !this.#disposed) {
297
368
  switch (change.type) {
298
369
  case 'set':
370
+ case 'touch':
299
371
  this.#deleted.delete(change.key);
300
372
  this.#dirty.add(change.key);
301
373
  break;
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,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAqCxC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,UAAU;IACZ,KAAK,CAAY;IACjB,UAAU,GAAG,IAAI,GAAG,EAAiB,CAAC;IACtC,OAAO,GAAsB,EAAE,CAAC;IACzC,QAAQ,GAA4B,IAAI,CAAC;IACzC,aAAa,GA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AAM,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"}
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;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC,CAAC;IACT,wEAAwE;IACxE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC5B;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,C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+ "version": "0.2.0-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
  */
@@ -58,6 +62,14 @@ export class BlazeCache {
58
62
  * Creates a cache that holds at most `capacity` entries (clamped to `>= 1`).
59
63
  */
60
64
  constructor(capacity: number);
65
+ /**
66
+ * Same lookup as [`get`](Self::get) — **without** recording a hit or a miss, and without
67
+ * marking the entry visited for SIEVE.
68
+ *
69
+ * The read for "is this here?" questions: it leaves the hit rate and the eviction order
70
+ * exactly as it found them, and it never reclaims an expired entry.
71
+ */
72
+ peek(key: string): any | undefined;
61
73
  /**
62
74
  * Removes every expired entry, returning the removed keys.
63
75
  */
@@ -78,6 +90,13 @@ export class BlazeCache {
78
90
  * can never evict itself.
79
91
  */
80
92
  set(key: string, value: any, ttl_ms: number | null | undefined, tags: string[]): void;
93
+ /**
94
+ * Number of stored entries that are present **and** not expired — expired-but-unpruned
95
+ * slots are not counted, so this always matches what `keys()`/`entries()` return.
96
+ *
97
+ * `O(1)` when no entry carries a TTL, otherwise a single oldest-first walk.
98
+ */
99
+ size(): number;
81
100
  /**
82
101
  * Counters: `{ hits, misses, evictions, expirations, invalidations, size, capacity }`.
83
102
  */
@@ -87,13 +106,19 @@ export class BlazeCache {
87
106
  */
88
107
  tagsOf(key: string): string[];
89
108
  /**
90
- * Maximum number of entries.
109
+ * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
110
+ * value is never changed. Returns `false` when the key is missing or expired.
111
+ *
112
+ * * `ttlMs` — `undefined`/`null` leaves the current deadline alone; a positive finite
113
+ * number replaces it with "now + ttlMs"; `0`, negatives and `NaN` drop the deadline
114
+ * (never expires), the same reading [`set`](Self::set) gives them.
91
115
  */
92
- readonly capacity: number;
116
+ touch(key: string, ttl_ms?: number | null): boolean;
93
117
  /**
94
- * Current number of stored entries (may include not-yet-pruned expired ones).
118
+ * Milliseconds until `key` expires, or `undefined` when it carries no TTL or the key is
119
+ * missing/expired. Purely observational: statistics and eviction state are untouched.
95
120
  */
96
- readonly size: number;
121
+ ttl(key: string): number | undefined;
97
122
  }
98
123
 
99
124
  /**
@@ -119,12 +144,15 @@ export interface InitOutput {
119
144
  readonly blazecache_keys: (a: number, b: number) => void;
120
145
  readonly blazecache_keysWithTag: (a: number, b: number, c: number, d: number) => void;
121
146
  readonly blazecache_new: (a: number) => number;
147
+ readonly blazecache_peek: (a: number, b: number, c: number) => number;
122
148
  readonly blazecache_prune: (a: number, b: number) => void;
123
149
  readonly blazecache_resetStats: (a: number) => void;
124
150
  readonly blazecache_set: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
125
151
  readonly blazecache_size: (a: number) => number;
126
152
  readonly blazecache_stats: (a: number, b: number) => void;
127
153
  readonly blazecache_tagsOf: (a: number, b: number, c: number, d: number) => void;
154
+ readonly blazecache_touch: (a: number, b: number, c: number, d: number, e: number) => number;
155
+ readonly blazecache_ttl: (a: number, b: number, c: number, d: number) => void;
128
156
  readonly setPanicHook: () => void;
129
157
  readonly __wbindgen_export: (a: number, b: number) => number;
130
158
  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
  }
@@ -168,6 +168,21 @@ export class BlazeCache {
168
168
  BlazeCacheFinalization.register(this, this.__wbg_ptr, this);
169
169
  return this;
170
170
  }
171
+ /**
172
+ * Same lookup as [`get`](Self::get) — **without** recording a hit or a miss, and without
173
+ * marking the entry visited for SIEVE.
174
+ *
175
+ * The read for "is this here?" questions: it leaves the hit rate and the eviction order
176
+ * exactly as it found them, and it never reclaims an expired entry.
177
+ * @param {string} key
178
+ * @returns {any | undefined}
179
+ */
180
+ peek(key) {
181
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
182
+ const len0 = WASM_VECTOR_LEN;
183
+ const ret = wasm.blazecache_peek(this.__wbg_ptr, ptr0, len0);
184
+ return takeObject(ret);
185
+ }
171
186
  /**
172
187
  * Removes every expired entry, returning the removed keys.
173
188
  * @returns {string[]}
@@ -214,10 +229,13 @@ export class BlazeCache {
214
229
  wasm.blazecache_set(this.__wbg_ptr, ptr0, len0, addHeapObject(value), !isLikeNone(ttl_ms), isLikeNone(ttl_ms) ? 0 : ttl_ms, ptr1, len1);
215
230
  }
216
231
  /**
217
- * Current number of stored entries (may include not-yet-pruned expired ones).
232
+ * Number of stored entries that are present **and** not expired — expired-but-unpruned
233
+ * slots are not counted, so this always matches what `keys()`/`entries()` return.
234
+ *
235
+ * `O(1)` when no entry carries a TTL, otherwise a single oldest-first walk.
218
236
  * @returns {number}
219
237
  */
220
- get size() {
238
+ size() {
221
239
  const ret = wasm.blazecache_size(this.__wbg_ptr);
222
240
  return ret >>> 0;
223
241
  }
@@ -260,6 +278,42 @@ export class BlazeCache {
260
278
  wasm.__wbindgen_add_to_stack_pointer(16);
261
279
  }
262
280
  }
281
+ /**
282
+ * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
283
+ * value is never changed. Returns `false` when the key is missing or expired.
284
+ *
285
+ * * `ttlMs` — `undefined`/`null` leaves the current deadline alone; a positive finite
286
+ * number replaces it with "now + ttlMs"; `0`, negatives and `NaN` drop the deadline
287
+ * (never expires), the same reading [`set`](Self::set) gives them.
288
+ * @param {string} key
289
+ * @param {number | null} [ttl_ms]
290
+ * @returns {boolean}
291
+ */
292
+ touch(key, ttl_ms) {
293
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
294
+ const len0 = WASM_VECTOR_LEN;
295
+ const ret = wasm.blazecache_touch(this.__wbg_ptr, ptr0, len0, !isLikeNone(ttl_ms), isLikeNone(ttl_ms) ? 0 : ttl_ms);
296
+ return ret !== 0;
297
+ }
298
+ /**
299
+ * Milliseconds until `key` expires, or `undefined` when it carries no TTL or the key is
300
+ * missing/expired. Purely observational: statistics and eviction state are untouched.
301
+ * @param {string} key
302
+ * @returns {number | undefined}
303
+ */
304
+ ttl(key) {
305
+ try {
306
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
307
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
308
+ const len0 = WASM_VECTOR_LEN;
309
+ wasm.blazecache_ttl(retptr, this.__wbg_ptr, ptr0, len0);
310
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
311
+ var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true);
312
+ return r0 === 0 ? undefined : r2;
313
+ } finally {
314
+ wasm.__wbindgen_add_to_stack_pointer(16);
315
+ }
316
+ }
263
317
  }
264
318
  if (Symbol.dispose) BlazeCache.prototype[Symbol.dispose] = BlazeCache.prototype.free;
265
319
 
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;