@blaze-cache/core 0.2.1-beta → 0.2.3-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 +53 -2
- package/dist/cache.d.ts +127 -7
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +234 -33
- package/dist/cache.js.map +1 -1
- package/dist/events.d.ts +84 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +179 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +130 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/pkg/blaze_cache_wasm.d.ts +51 -0
- package/pkg/blaze_cache_wasm.js +167 -0
- package/pkg/blaze_cache_wasm_bg.wasm +0 -0
- package/pkg/blaze_cache_wasm_bg.wasm.d.ts +7 -0
- package/pkg/package.json +1 -1
package/pkg/blaze_cache_wasm.js
CHANGED
|
@@ -28,6 +28,26 @@ export class BlazeCache {
|
|
|
28
28
|
clear() {
|
|
29
29
|
wasm.blazecache_clear(this.__wbg_ptr);
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Batch delete: returns `1` for each key that was present, `0` otherwise.
|
|
33
|
+
* @param {string[]} keys
|
|
34
|
+
* @returns {Uint8Array}
|
|
35
|
+
*/
|
|
36
|
+
deleteMany(keys) {
|
|
37
|
+
try {
|
|
38
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
39
|
+
const ptr0 = passArrayJsValueToWasm0(keys, wasm.__wbindgen_export);
|
|
40
|
+
const len0 = WASM_VECTOR_LEN;
|
|
41
|
+
wasm.blazecache_deleteMany(retptr, this.__wbg_ptr, ptr0, len0);
|
|
42
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
43
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
44
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
45
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
46
|
+
return v2;
|
|
47
|
+
} finally {
|
|
48
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
31
51
|
/**
|
|
32
52
|
* Removes `key`, returning whether it was there.
|
|
33
53
|
* @param {string} key
|
|
@@ -39,6 +59,28 @@ export class BlazeCache {
|
|
|
39
59
|
const ret = wasm.blazecache_delete(this.__wbg_ptr, ptr0, len0);
|
|
40
60
|
return ret !== 0;
|
|
41
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Takes every drop recorded since the last call as
|
|
64
|
+
* `[{ key, value, reason: "evict" | "expire" }, …]`.
|
|
65
|
+
*
|
|
66
|
+
* Explicit `delete`, `deleteMany`, `invalidateTags`, `prune` and `clear` never show up
|
|
67
|
+
* here — the host issued those and already knows the result. Call this after each
|
|
68
|
+
* operation that could have reclaimed memory (any write, any read when TTLs exist)
|
|
69
|
+
* while drop listeners are installed.
|
|
70
|
+
* @returns {Array<any>}
|
|
71
|
+
*/
|
|
72
|
+
drainDrops() {
|
|
73
|
+
const ret = wasm.blazecache_drainDrops(this.__wbg_ptr);
|
|
74
|
+
return takeObject(ret);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* `true` while the drop log is being collected.
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
dropTracking() {
|
|
81
|
+
const ret = wasm.blazecache_dropTracking(this.__wbg_ptr);
|
|
82
|
+
return ret !== 0;
|
|
83
|
+
}
|
|
42
84
|
/**
|
|
43
85
|
* Full snapshot — `{ key, value, ttlMs, tags }` for every live entry, oldest first.
|
|
44
86
|
*
|
|
@@ -62,6 +104,27 @@ export class BlazeCache {
|
|
|
62
104
|
const ret = wasm.blazecache_entry(this.__wbg_ptr, ptr0, len0);
|
|
63
105
|
return takeObject(ret);
|
|
64
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Batch get: looks up every key in one boundary crossing. Returns `JsValue::UNDEFINED`
|
|
109
|
+
* for missing or expired entries. Each hit marks the entry visited for SIEVE.
|
|
110
|
+
* @param {string[]} keys
|
|
111
|
+
* @returns {any[]}
|
|
112
|
+
*/
|
|
113
|
+
getMany(keys) {
|
|
114
|
+
try {
|
|
115
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
116
|
+
const ptr0 = passArrayJsValueToWasm0(keys, wasm.__wbindgen_export);
|
|
117
|
+
const len0 = WASM_VECTOR_LEN;
|
|
118
|
+
wasm.blazecache_getMany(retptr, this.__wbg_ptr, ptr0, len0);
|
|
119
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
120
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
121
|
+
var v2 = getArrayJsValueFromWasm0(r0, r1);
|
|
122
|
+
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
123
|
+
return v2;
|
|
124
|
+
} finally {
|
|
125
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
65
128
|
/**
|
|
66
129
|
* Returns the value stored under `key`, or `undefined` when it is missing/expired.
|
|
67
130
|
*
|
|
@@ -75,6 +138,26 @@ export class BlazeCache {
|
|
|
75
138
|
const ret = wasm.blazecache_get(this.__wbg_ptr, ptr0, len0);
|
|
76
139
|
return takeObject(ret);
|
|
77
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Batch has: returns `1` for each key that is present and not expired, `0` otherwise.
|
|
143
|
+
* @param {string[]} keys
|
|
144
|
+
* @returns {Uint8Array}
|
|
145
|
+
*/
|
|
146
|
+
hasMany(keys) {
|
|
147
|
+
try {
|
|
148
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
149
|
+
const ptr0 = passArrayJsValueToWasm0(keys, wasm.__wbindgen_export);
|
|
150
|
+
const len0 = WASM_VECTOR_LEN;
|
|
151
|
+
wasm.blazecache_hasMany(retptr, this.__wbg_ptr, ptr0, len0);
|
|
152
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
153
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
154
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
155
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
156
|
+
return v2;
|
|
157
|
+
} finally {
|
|
158
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
78
161
|
/**
|
|
79
162
|
* `true` when `key` carries `tag`.
|
|
80
163
|
* @param {string} key
|
|
@@ -217,6 +300,41 @@ export class BlazeCache {
|
|
|
217
300
|
resetStats() {
|
|
218
301
|
wasm.blazecache_resetStats(this.__wbg_ptr);
|
|
219
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Starts (or stops) recording entries the cache drops **by itself** — capacity
|
|
305
|
+
* evictions and TTL expirations — so the host can observe them via
|
|
306
|
+
* [`drain_drops`](Self::drain_drops).
|
|
307
|
+
*
|
|
308
|
+
* Off by default: while off, the core pays nothing but a branch at the moment an
|
|
309
|
+
* entry dies, and `drain_drops()` returns an empty array. Turning it off also clears
|
|
310
|
+
* whatever has been recorded but not yet drained.
|
|
311
|
+
* @param {boolean} enabled
|
|
312
|
+
*/
|
|
313
|
+
setDropTracking(enabled) {
|
|
314
|
+
wasm.blazecache_setDropTracking(this.__wbg_ptr, enabled);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Batch set: stores every key/value pair in one boundary crossing.
|
|
318
|
+
*
|
|
319
|
+
* `ttl_ms[i] < 0` means no expiry. `tag_offsets[i]`..`tag_offsets[i+1]` index into
|
|
320
|
+
* `tags_flat` for the tags of entry `i`.
|
|
321
|
+
* @param {string[]} keys
|
|
322
|
+
* @param {any} values
|
|
323
|
+
* @param {Float64Array} ttl_ms
|
|
324
|
+
* @param {string[]} tags_flat
|
|
325
|
+
* @param {Uint32Array} tag_offsets
|
|
326
|
+
*/
|
|
327
|
+
setMany(keys, values, ttl_ms, tags_flat, tag_offsets) {
|
|
328
|
+
const ptr0 = passArrayJsValueToWasm0(keys, wasm.__wbindgen_export);
|
|
329
|
+
const len0 = WASM_VECTOR_LEN;
|
|
330
|
+
const ptr1 = passArrayF64ToWasm0(ttl_ms, wasm.__wbindgen_export);
|
|
331
|
+
const len1 = WASM_VECTOR_LEN;
|
|
332
|
+
const ptr2 = passArrayJsValueToWasm0(tags_flat, wasm.__wbindgen_export);
|
|
333
|
+
const len2 = WASM_VECTOR_LEN;
|
|
334
|
+
const ptr3 = passArray32ToWasm0(tag_offsets, wasm.__wbindgen_export);
|
|
335
|
+
const len3 = WASM_VECTOR_LEN;
|
|
336
|
+
wasm.blazecache_setMany(this.__wbg_ptr, ptr0, len0, addHeapObject(values), ptr1, len1, ptr2, len2, ptr3, len3);
|
|
337
|
+
}
|
|
220
338
|
/**
|
|
221
339
|
* Stores `value` under `key`.
|
|
222
340
|
*
|
|
@@ -375,6 +493,18 @@ function __wbg_get_imports() {
|
|
|
375
493
|
wasm.__wbindgen_export3(deferred0_0, deferred0_1, 1);
|
|
376
494
|
}
|
|
377
495
|
},
|
|
496
|
+
__wbg_from_296ca31f8d0f1c52: function(arg0) {
|
|
497
|
+
const ret = Array.from(getObject(arg0));
|
|
498
|
+
return addHeapObject(ret);
|
|
499
|
+
},
|
|
500
|
+
__wbg_get_6c896e0571ddae51: function(arg0, arg1) {
|
|
501
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
502
|
+
return addHeapObject(ret);
|
|
503
|
+
},
|
|
504
|
+
__wbg_length_d4bdea10311bd9cf: function(arg0) {
|
|
505
|
+
const ret = getObject(arg0).length;
|
|
506
|
+
return ret;
|
|
507
|
+
},
|
|
378
508
|
__wbg_new_227d7c05414eb861: function() {
|
|
379
509
|
const ret = new Error();
|
|
380
510
|
return addHeapObject(ret);
|
|
@@ -487,6 +617,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
487
617
|
return result;
|
|
488
618
|
}
|
|
489
619
|
|
|
620
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
621
|
+
ptr = ptr >>> 0;
|
|
622
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
623
|
+
}
|
|
624
|
+
|
|
490
625
|
let cachedDataViewMemory0 = null;
|
|
491
626
|
function getDataViewMemory0() {
|
|
492
627
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -495,10 +630,26 @@ function getDataViewMemory0() {
|
|
|
495
630
|
return cachedDataViewMemory0;
|
|
496
631
|
}
|
|
497
632
|
|
|
633
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
634
|
+
function getFloat64ArrayMemory0() {
|
|
635
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
636
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
637
|
+
}
|
|
638
|
+
return cachedFloat64ArrayMemory0;
|
|
639
|
+
}
|
|
640
|
+
|
|
498
641
|
function getStringFromWasm0(ptr, len) {
|
|
499
642
|
return decodeText(ptr >>> 0, len);
|
|
500
643
|
}
|
|
501
644
|
|
|
645
|
+
let cachedUint32ArrayMemory0 = null;
|
|
646
|
+
function getUint32ArrayMemory0() {
|
|
647
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
648
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
649
|
+
}
|
|
650
|
+
return cachedUint32ArrayMemory0;
|
|
651
|
+
}
|
|
652
|
+
|
|
502
653
|
let cachedUint8ArrayMemory0 = null;
|
|
503
654
|
function getUint8ArrayMemory0() {
|
|
504
655
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
@@ -526,6 +677,20 @@ function isLikeNone(x) {
|
|
|
526
677
|
return x === undefined || x === null;
|
|
527
678
|
}
|
|
528
679
|
|
|
680
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
681
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
682
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
683
|
+
WASM_VECTOR_LEN = arg.length;
|
|
684
|
+
return ptr;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
688
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
689
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
690
|
+
WASM_VECTOR_LEN = arg.length;
|
|
691
|
+
return ptr;
|
|
692
|
+
}
|
|
693
|
+
|
|
529
694
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
530
695
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
531
696
|
const mem = getDataViewMemory0();
|
|
@@ -614,6 +779,8 @@ function __wbg_finalize_init(instance, module) {
|
|
|
614
779
|
wasm = instance.exports;
|
|
615
780
|
wasmModule = module;
|
|
616
781
|
cachedDataViewMemory0 = null;
|
|
782
|
+
cachedFloat64ArrayMemory0 = null;
|
|
783
|
+
cachedUint32ArrayMemory0 = null;
|
|
617
784
|
cachedUint8ArrayMemory0 = null;
|
|
618
785
|
return wasm;
|
|
619
786
|
}
|
|
Binary file
|
|
@@ -5,10 +5,15 @@ export const __wbg_blazecache_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const blazecache_capacity: (a: number) => number;
|
|
6
6
|
export const blazecache_clear: (a: number) => void;
|
|
7
7
|
export const blazecache_delete: (a: number, b: number, c: number) => number;
|
|
8
|
+
export const blazecache_deleteMany: (a: number, b: number, c: number, d: number) => void;
|
|
9
|
+
export const blazecache_drainDrops: (a: number) => number;
|
|
10
|
+
export const blazecache_dropTracking: (a: number) => number;
|
|
8
11
|
export const blazecache_entries: (a: number) => number;
|
|
9
12
|
export const blazecache_entry: (a: number, b: number, c: number) => number;
|
|
10
13
|
export const blazecache_get: (a: number, b: number, c: number) => number;
|
|
14
|
+
export const blazecache_getMany: (a: number, b: number, c: number, d: number) => void;
|
|
11
15
|
export const blazecache_has: (a: number, b: number, c: number) => number;
|
|
16
|
+
export const blazecache_hasMany: (a: number, b: number, c: number, d: number) => void;
|
|
12
17
|
export const blazecache_hasTag: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
13
18
|
export const blazecache_invalidateTags: (a: number, b: number, c: number, d: number) => void;
|
|
14
19
|
export const blazecache_keys: (a: number, b: number) => void;
|
|
@@ -18,6 +23,8 @@ export const blazecache_peek: (a: number, b: number, c: number) => number;
|
|
|
18
23
|
export const blazecache_prune: (a: number, b: number) => void;
|
|
19
24
|
export const blazecache_resetStats: (a: number) => void;
|
|
20
25
|
export const blazecache_set: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
26
|
+
export const blazecache_setDropTracking: (a: number, b: number) => void;
|
|
27
|
+
export const blazecache_setMany: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
21
28
|
export const blazecache_size: (a: number) => number;
|
|
22
29
|
export const blazecache_stats: (a: number, b: number) => void;
|
|
23
30
|
export const blazecache_tagsOf: (a: number, b: number, c: number, d: number) => void;
|