@blaze-cache/core 0.4.0-beta.0 → 0.4.0-beta.2
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 +28 -12
- package/dist/cache.d.ts +46 -22
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +467 -54
- package/dist/cache.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/persistence/indexeddb.d.ts +16 -2
- package/dist/persistence/indexeddb.d.ts.map +1 -1
- package/dist/persistence/indexeddb.js +280 -55
- package/dist/persistence/indexeddb.js.map +1 -1
- package/dist/persistence/types.d.ts +271 -0
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/wasm.d.ts +79 -1
- package/dist/wasm.d.ts.map +1 -1
- package/dist/wasm.js +142 -0
- package/dist/wasm.js.map +1 -1
- package/package.json +2 -1
- package/pkg/blaze_cache_wasm.d.ts +11 -7
- package/pkg/blaze_cache_wasm.js +11 -7
- package/pkg/blaze_cache_wasm_bg.wasm +0 -0
- package/pkg/package.json +1 -1
|
@@ -69,9 +69,11 @@ export class BlazeCache {
|
|
|
69
69
|
*
|
|
70
70
|
* # Host contract
|
|
71
71
|
*
|
|
72
|
-
* `ptr`/`len` must address `len` bytes of valid UTF-8
|
|
73
|
-
* bytes it encoded from a JS string (ASCII fast path or
|
|
74
|
-
*
|
|
72
|
+
* `ptr`/`len` must address `len` bytes of valid UTF-8 in the current scratch buffer.
|
|
73
|
+
* The wrapper only ever passes bytes it encoded from a JS string (ASCII fast path or
|
|
74
|
+
* `TextEncoder`). Anything else — a stale pointer after a scratch reallocation, an
|
|
75
|
+
* out-of-range length, invalid UTF-8 — is treated as a miss instead of undefined
|
|
76
|
+
* behaviour (see [`with_raw_key`]).
|
|
75
77
|
*/
|
|
76
78
|
getRaw(ptr: number, len: number): any | undefined;
|
|
77
79
|
/**
|
|
@@ -116,8 +118,8 @@ export class BlazeCache {
|
|
|
116
118
|
* * above [`MAX_CAPACITY`] — clamped down, because `capacity()` reports it back and
|
|
117
119
|
* nobody builds a browser cache meant to hold a billion entries.
|
|
118
120
|
*
|
|
119
|
-
* The core
|
|
120
|
-
*
|
|
121
|
+
* The core reserves at most a small fixed number of index buckets, so even an
|
|
122
|
+
* unvalidated number cannot abort the instance with a huge up-front allocation.
|
|
121
123
|
*/
|
|
122
124
|
constructor(capacity: number);
|
|
123
125
|
/**
|
|
@@ -152,7 +154,8 @@ export class BlazeCache {
|
|
|
152
154
|
* `ttl_ms[i] < 0` means no expiry. `tag_offsets[i]`..`tag_offsets[i+1]` index into
|
|
153
155
|
* `tags_flat` for the tags of entry `i`. Those offsets come from JS, so they are
|
|
154
156
|
* clamped rather than trusted: a non-monotonic or out-of-range pair yields no tags
|
|
155
|
-
* for that entry instead of panicking and trapping the wasm instance.
|
|
157
|
+
* for that entry instead of panicking and trapping the wasm instance. Keys are looked
|
|
158
|
+
* up by slice, so overwriting an existing key pays no key allocation.
|
|
156
159
|
*/
|
|
157
160
|
setMany(keys: string[], values: any, ttl_ms: Float64Array | number[], tags_flat: string[], tag_offsets: Uint32Array | number[]): void;
|
|
158
161
|
/**
|
|
@@ -170,7 +173,8 @@ export class BlazeCache {
|
|
|
170
173
|
*
|
|
171
174
|
* Replacing a key refreshes its TTL **and** its tags, and re-queues it as the newest
|
|
172
175
|
* entry. Capacity pressure is applied before the new node becomes visible, so a write
|
|
173
|
-
* can never evict itself.
|
|
176
|
+
* can never evict itself. The key is looked up by slice first, so an overwrite never
|
|
177
|
+
* allocates a `String` just to throw it away again.
|
|
174
178
|
*/
|
|
175
179
|
set(key: string, value: any, ttl_ms: number | null | undefined, tags: string[]): void;
|
|
176
180
|
/**
|
package/pkg/blaze_cache_wasm.js
CHANGED
|
@@ -146,9 +146,11 @@ export class BlazeCache {
|
|
|
146
146
|
*
|
|
147
147
|
* # Host contract
|
|
148
148
|
*
|
|
149
|
-
* `ptr`/`len` must address `len` bytes of valid UTF-8
|
|
150
|
-
* bytes it encoded from a JS string (ASCII fast path or
|
|
151
|
-
*
|
|
149
|
+
* `ptr`/`len` must address `len` bytes of valid UTF-8 in the current scratch buffer.
|
|
150
|
+
* The wrapper only ever passes bytes it encoded from a JS string (ASCII fast path or
|
|
151
|
+
* `TextEncoder`). Anything else — a stale pointer after a scratch reallocation, an
|
|
152
|
+
* out-of-range length, invalid UTF-8 — is treated as a miss instead of undefined
|
|
153
|
+
* behaviour (see [`with_raw_key`]).
|
|
152
154
|
* @param {number} ptr
|
|
153
155
|
* @param {number} len
|
|
154
156
|
* @returns {any | undefined}
|
|
@@ -291,8 +293,8 @@ export class BlazeCache {
|
|
|
291
293
|
* * above [`MAX_CAPACITY`] — clamped down, because `capacity()` reports it back and
|
|
292
294
|
* nobody builds a browser cache meant to hold a billion entries.
|
|
293
295
|
*
|
|
294
|
-
* The core
|
|
295
|
-
*
|
|
296
|
+
* The core reserves at most a small fixed number of index buckets, so even an
|
|
297
|
+
* unvalidated number cannot abort the instance with a huge up-front allocation.
|
|
296
298
|
* @param {number} capacity
|
|
297
299
|
*/
|
|
298
300
|
constructor(capacity) {
|
|
@@ -358,7 +360,8 @@ export class BlazeCache {
|
|
|
358
360
|
* `ttl_ms[i] < 0` means no expiry. `tag_offsets[i]`..`tag_offsets[i+1]` index into
|
|
359
361
|
* `tags_flat` for the tags of entry `i`. Those offsets come from JS, so they are
|
|
360
362
|
* clamped rather than trusted: a non-monotonic or out-of-range pair yields no tags
|
|
361
|
-
* for that entry instead of panicking and trapping the wasm instance.
|
|
363
|
+
* for that entry instead of panicking and trapping the wasm instance. Keys are looked
|
|
364
|
+
* up by slice, so overwriting an existing key pays no key allocation.
|
|
362
365
|
* @param {string[]} keys
|
|
363
366
|
* @param {any} values
|
|
364
367
|
* @param {Float64Array | number[]} ttl_ms
|
|
@@ -406,7 +409,8 @@ export class BlazeCache {
|
|
|
406
409
|
*
|
|
407
410
|
* Replacing a key refreshes its TTL **and** its tags, and re-queues it as the newest
|
|
408
411
|
* entry. Capacity pressure is applied before the new node becomes visible, so a write
|
|
409
|
-
* can never evict itself.
|
|
412
|
+
* can never evict itself. The key is looked up by slice first, so an overwrite never
|
|
413
|
+
* allocates a `String` just to throw it away again.
|
|
410
414
|
* @param {string} key
|
|
411
415
|
* @param {any} value
|
|
412
416
|
* @param {number | null | undefined} ttl_ms
|
|
Binary file
|