@memberjunction/redis-provider 6.3.0-edge.0 → 6.3.0-edge.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/dist/RedisLocalStorageProvider.d.ts +49 -1
- package/dist/RedisLocalStorageProvider.d.ts.map +1 -1
- package/dist/RedisLocalStorageProvider.js +579 -3
- package/dist/RedisLocalStorageProvider.js.map +1 -1
- package/dist/TwoTierCacheStorageProvider.d.ts +136 -0
- package/dist/TwoTierCacheStorageProvider.d.ts.map +1 -0
- package/dist/TwoTierCacheStorageProvider.js +497 -0
- package/dist/TwoTierCacheStorageProvider.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Two-tier caching provider (L1 in-process frozen CoW + L2 distributed Redis).
|
|
3
|
+
*
|
|
4
|
+
* Implements {@link ILocalStorageProvider} with:
|
|
5
|
+
* - **L1 RAM**: in-process byte-bounded LRU cache with deep-frozen objects (0.001 ms hits, reference sharing)
|
|
6
|
+
* - **L2 Redis**: persistent shared cache across all cluster nodes (via RedisLocalStorageProvider)
|
|
7
|
+
* - **Differential Row Patching**: peer row_delta events update L1 via Copy-on-Write without re-fetching
|
|
8
|
+
* - **Automatic Sync & Eviction**: pub/sub event integration and reconciliation flushes
|
|
9
|
+
*
|
|
10
|
+
* @module @memberjunction/redis-provider
|
|
11
|
+
*/
|
|
12
|
+
import { LogError } from '@memberjunction/core';
|
|
13
|
+
import { UUIDsEqual } from '@memberjunction/global';
|
|
14
|
+
/**
|
|
15
|
+
* Deep-freezes an object tree recursively using a WeakSet to guard against cycles.
|
|
16
|
+
* When an object or row is already frozen, it returns immediately in O(1).
|
|
17
|
+
*/
|
|
18
|
+
export function DeepFreeze(obj, visited = new WeakSet()) {
|
|
19
|
+
if (obj === null || typeof obj !== 'object') {
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
if (Object.isFrozen(obj) || visited.has(obj)) {
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
visited.add(obj);
|
|
26
|
+
if (Array.isArray(obj)) {
|
|
27
|
+
for (let i = 0; i < obj.length; i++) {
|
|
28
|
+
DeepFreeze(obj[i], visited);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const record = obj;
|
|
33
|
+
for (const key of Object.keys(record)) {
|
|
34
|
+
DeepFreeze(record[key], visited);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
return Object.freeze(obj);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fast approximate byte size estimator for L1 heap budget management.
|
|
46
|
+
*/
|
|
47
|
+
function estimateSizeBytes(value) {
|
|
48
|
+
if (value === null || value === undefined)
|
|
49
|
+
return 8;
|
|
50
|
+
if (typeof value === 'string')
|
|
51
|
+
return value.length * 2;
|
|
52
|
+
if (typeof value === 'number')
|
|
53
|
+
return 8;
|
|
54
|
+
if (typeof value === 'boolean')
|
|
55
|
+
return 4;
|
|
56
|
+
if (Array.isArray(value)) {
|
|
57
|
+
if (value.length === 0)
|
|
58
|
+
return 32;
|
|
59
|
+
const sampleSize = estimateSizeBytes(value[0]);
|
|
60
|
+
return 32 + sampleSize * value.length;
|
|
61
|
+
}
|
|
62
|
+
if (typeof value === 'object') {
|
|
63
|
+
const obj = value;
|
|
64
|
+
if (Array.isArray(obj.results)) {
|
|
65
|
+
const resultsSize = estimateSizeBytes(obj.results);
|
|
66
|
+
return 256 + resultsSize;
|
|
67
|
+
}
|
|
68
|
+
let size = 64;
|
|
69
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
70
|
+
size += k.length * 2 + (typeof v === 'string' ? v.length * 2 : 16);
|
|
71
|
+
}
|
|
72
|
+
return size;
|
|
73
|
+
}
|
|
74
|
+
return 64;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Matches two record rows by primary key fields using NormalizeUUID / UUIDsEqual.
|
|
78
|
+
*/
|
|
79
|
+
function rowsMatch(rowA, rowB, pkFields) {
|
|
80
|
+
for (const pk of pkFields) {
|
|
81
|
+
const valA = rowA[pk];
|
|
82
|
+
const valB = rowB[pk];
|
|
83
|
+
if (valA === undefined || valB === undefined || valA === null || valB === null) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (!UUIDsEqual(String(valA), String(valB))) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Two-tier cache storage provider combining an in-process deep-frozen L1 LRU heap cache
|
|
94
|
+
* with a cluster-shared L2 Redis backend.
|
|
95
|
+
*/
|
|
96
|
+
export class TwoTierCacheStorageProvider {
|
|
97
|
+
constructor(redisProvider, config) {
|
|
98
|
+
/**
|
|
99
|
+
* `true` — L1 stores and returns deep-frozen live object references for 0.001 ms hits.
|
|
100
|
+
*/
|
|
101
|
+
this.SharesReferences = true;
|
|
102
|
+
/**
|
|
103
|
+
* `true` — backed by distributed Redis for persistence across process restarts.
|
|
104
|
+
*/
|
|
105
|
+
this.SupportsCrossProcessPersistence = true;
|
|
106
|
+
/**
|
|
107
|
+
* `true` — L2 Redis is shared across processes and replicas.
|
|
108
|
+
*/
|
|
109
|
+
this.SharedAcrossProcesses = true;
|
|
110
|
+
this._l1Map = new Map();
|
|
111
|
+
this._currentL1Bytes = 0;
|
|
112
|
+
this._unsubs = [];
|
|
113
|
+
this._redis = redisProvider;
|
|
114
|
+
this._maxL1Bytes = config?.MaxL1Bytes ?? 128 * 1024 * 1024;
|
|
115
|
+
const categories = config?.CategoriesInL1 ?? ['RunViewCache', 'DatasetCache', 'RunQueryCache'];
|
|
116
|
+
this._categoriesInL1 = new Set(categories);
|
|
117
|
+
// Subscribe to Redis cache events for automatic peer synchronization
|
|
118
|
+
this._unsubs.push(this._redis.OnCacheChanged(event => this.handleRedisCacheChanged(event)));
|
|
119
|
+
this._unsubs.push(this._redis.OnReconciliationRequired(() => this.ClearL1()));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Exposes the underlying L2 Redis provider.
|
|
123
|
+
*/
|
|
124
|
+
get RedisProvider() {
|
|
125
|
+
return this._redis;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Current total bytes occupied by entries in the L1 RAM cache.
|
|
129
|
+
*/
|
|
130
|
+
get CurrentL1Bytes() {
|
|
131
|
+
return this._currentL1Bytes;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Total count of slots currently stored in L1.
|
|
135
|
+
*/
|
|
136
|
+
get L1EntryCount() {
|
|
137
|
+
return this._l1Map.size;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Retrieves an item from L1 if eligible and cached, otherwise reads from Redis L2 and populates L1.
|
|
141
|
+
*/
|
|
142
|
+
async GetItem(key, category) {
|
|
143
|
+
const cat = category ?? 'default';
|
|
144
|
+
if (!this._categoriesInL1.has(cat)) {
|
|
145
|
+
return this._redis.GetItem(key, cat);
|
|
146
|
+
}
|
|
147
|
+
const l1Key = this.buildL1Key(key, cat);
|
|
148
|
+
const entry = this._l1Map.get(l1Key);
|
|
149
|
+
if (entry) {
|
|
150
|
+
if (entry.ExpiresAt !== null && Date.now() > entry.ExpiresAt) {
|
|
151
|
+
this.deleteL1Entry(l1Key);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// LRU refresh: delete and re-insert at tail
|
|
155
|
+
this._l1Map.delete(l1Key);
|
|
156
|
+
this._l1Map.set(l1Key, entry);
|
|
157
|
+
return entry.Value;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Miss in L1: fetch from L2 Redis
|
|
161
|
+
const value = await this._redis.GetItem(key, cat);
|
|
162
|
+
if (value !== null) {
|
|
163
|
+
this.setL1Entry(key, value, cat, undefined);
|
|
164
|
+
}
|
|
165
|
+
return value;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Batched retrieval across L1 and L2.
|
|
169
|
+
*/
|
|
170
|
+
async GetItems(keys, category) {
|
|
171
|
+
const cat = category ?? 'default';
|
|
172
|
+
if (!this._categoriesInL1.has(cat) || keys.length === 0) {
|
|
173
|
+
return this._redis.GetItems(keys, cat);
|
|
174
|
+
}
|
|
175
|
+
const result = new Map();
|
|
176
|
+
const missingKeys = [];
|
|
177
|
+
for (const key of new Set(keys)) {
|
|
178
|
+
const l1Key = this.buildL1Key(key, cat);
|
|
179
|
+
const entry = this._l1Map.get(l1Key);
|
|
180
|
+
if (entry) {
|
|
181
|
+
if (entry.ExpiresAt !== null && Date.now() > entry.ExpiresAt) {
|
|
182
|
+
this.deleteL1Entry(l1Key);
|
|
183
|
+
missingKeys.push(key);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
// LRU refresh
|
|
187
|
+
this._l1Map.delete(l1Key);
|
|
188
|
+
this._l1Map.set(l1Key, entry);
|
|
189
|
+
result.set(key, entry.Value);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
missingKeys.push(key);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (missingKeys.length > 0) {
|
|
197
|
+
const redisMap = await this._redis.GetItems(missingKeys, cat);
|
|
198
|
+
for (const [key, val] of redisMap.entries()) {
|
|
199
|
+
if (val !== null) {
|
|
200
|
+
this.setL1Entry(key, val, cat, undefined);
|
|
201
|
+
}
|
|
202
|
+
result.set(key, val);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Stores a value in L1 (if eligible, deep-frozen) and writes through to L2 Redis.
|
|
209
|
+
*/
|
|
210
|
+
async SetItem(key, value, category, options) {
|
|
211
|
+
const cat = category ?? 'default';
|
|
212
|
+
if (this._categoriesInL1.has(cat)) {
|
|
213
|
+
const frozen = DeepFreeze(value);
|
|
214
|
+
this.setL1Entry(key, frozen, cat, options);
|
|
215
|
+
}
|
|
216
|
+
await this._redis.SetItem(key, value, cat, options);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Removes an item from L1 and L2 Redis.
|
|
220
|
+
*/
|
|
221
|
+
async Remove(key, category) {
|
|
222
|
+
const cat = category ?? 'default';
|
|
223
|
+
const l1Key = this.buildL1Key(key, cat);
|
|
224
|
+
this.deleteL1Entry(l1Key);
|
|
225
|
+
await this._redis.Remove(key, cat);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Clears all items in a category from L1 and L2 Redis.
|
|
229
|
+
*/
|
|
230
|
+
async ClearCategory(category) {
|
|
231
|
+
const cat = category || 'default';
|
|
232
|
+
this.clearCategoryInL1(cat);
|
|
233
|
+
await this._redis.ClearCategory(cat);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Clears all items in a category from L1 and L2 Redis, returning detailed status.
|
|
237
|
+
*/
|
|
238
|
+
async ClearCategoryChecked(category) {
|
|
239
|
+
const cat = category || 'default';
|
|
240
|
+
this.clearCategoryInL1(cat);
|
|
241
|
+
return this._redis.ClearCategoryChecked(cat);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Applies a differential row update to L1 RAM and delegates to L2 Redis.
|
|
245
|
+
*/
|
|
246
|
+
async ApplyRunViewRowDelta(fingerprint, deltaPayloadJson, updatedSlotValue, options) {
|
|
247
|
+
// Immediately store deep-frozen updated value into L1
|
|
248
|
+
const frozenSlot = DeepFreeze(updatedSlotValue);
|
|
249
|
+
this.setL1Entry(fingerprint, frozenSlot, 'RunViewCache', options);
|
|
250
|
+
// Delegate to L2 Redis
|
|
251
|
+
const applied = await this._redis.ApplyRunViewRowDelta(fingerprint, deltaPayloadJson, updatedSlotValue, options);
|
|
252
|
+
if (!applied) {
|
|
253
|
+
// Redis slot had expired, was cold, or was stored as string: fall back to full SetItem
|
|
254
|
+
await this._redis.SetItem(fingerprint, updatedSlotValue, 'RunViewCache', options);
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Checks if a key exists in L1 or L2 Redis.
|
|
260
|
+
*/
|
|
261
|
+
async Exists(key, category) {
|
|
262
|
+
const cat = category ?? 'default';
|
|
263
|
+
if (this.HasL1Key(key, cat)) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
return this._redis.Exists(key, cat);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Checks if a live, unexpired key exists in L1 RAM.
|
|
270
|
+
*/
|
|
271
|
+
HasL1Key(key, category) {
|
|
272
|
+
const cat = category ?? 'default';
|
|
273
|
+
const l1Key = this.buildL1Key(key, cat);
|
|
274
|
+
const entry = this._l1Map.get(l1Key);
|
|
275
|
+
if (!entry)
|
|
276
|
+
return false;
|
|
277
|
+
if (entry.ExpiresAt !== null && Date.now() > entry.ExpiresAt) {
|
|
278
|
+
this.deleteL1Entry(l1Key);
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Drops all entries currently in L1 RAM.
|
|
285
|
+
*/
|
|
286
|
+
ClearL1() {
|
|
287
|
+
this._l1Map.clear();
|
|
288
|
+
this._currentL1Bytes = 0;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Cleans up all event listeners and frees L1 memory.
|
|
292
|
+
*/
|
|
293
|
+
Dispose() {
|
|
294
|
+
for (const unsub of this._unsubs) {
|
|
295
|
+
unsub();
|
|
296
|
+
}
|
|
297
|
+
this._unsubs.length = 0;
|
|
298
|
+
this.ClearL1();
|
|
299
|
+
}
|
|
300
|
+
// ========================================================================
|
|
301
|
+
// Delegated ILocalStorageProvider Distributed Primitives
|
|
302
|
+
// ========================================================================
|
|
303
|
+
async GetCategoryKeys(category) {
|
|
304
|
+
return this._redis.GetCategoryKeys(category);
|
|
305
|
+
}
|
|
306
|
+
async GetIndexGroupKeys(category, group) {
|
|
307
|
+
return this._redis.GetIndexGroupKeys(category, group);
|
|
308
|
+
}
|
|
309
|
+
async WithKeyLock(key, category, work) {
|
|
310
|
+
return this._redis.WithKeyLock(key, category, work);
|
|
311
|
+
}
|
|
312
|
+
async TryAcquireLease(name, ttlMs) {
|
|
313
|
+
return this._redis.TryAcquireLease(name, ttlMs);
|
|
314
|
+
}
|
|
315
|
+
async ReleaseLease(name) {
|
|
316
|
+
return this._redis.ReleaseLease(name);
|
|
317
|
+
}
|
|
318
|
+
async GetTTL(key, category) {
|
|
319
|
+
return this._redis.GetTTL(key, category);
|
|
320
|
+
}
|
|
321
|
+
async Ping() {
|
|
322
|
+
return this._redis.Ping();
|
|
323
|
+
}
|
|
324
|
+
async Disconnect() {
|
|
325
|
+
this.Dispose();
|
|
326
|
+
await this._redis.Disconnect();
|
|
327
|
+
}
|
|
328
|
+
OnCacheChanged(callback) {
|
|
329
|
+
return this._redis.OnCacheChanged(callback);
|
|
330
|
+
}
|
|
331
|
+
OnReconciliationRequired(callback) {
|
|
332
|
+
return this._redis.OnReconciliationRequired(callback);
|
|
333
|
+
}
|
|
334
|
+
// ========================================================================
|
|
335
|
+
// Internal L1 Management & Peer Sync
|
|
336
|
+
// ========================================================================
|
|
337
|
+
buildL1Key(key, category) {
|
|
338
|
+
return `${category}::${key}`;
|
|
339
|
+
}
|
|
340
|
+
setL1Entry(key, value, category, options) {
|
|
341
|
+
if (!this._categoriesInL1.has(category)) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const l1Key = this.buildL1Key(key, category);
|
|
345
|
+
const frozen = DeepFreeze(value);
|
|
346
|
+
const sizeBytes = estimateSizeBytes(frozen);
|
|
347
|
+
if (sizeBytes > this._maxL1Bytes) {
|
|
348
|
+
// Slot is larger than total L1 budget; do not store in L1
|
|
349
|
+
this.deleteL1Entry(l1Key);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
let expiresAt = null;
|
|
353
|
+
if (typeof options === 'number' && options > 0) {
|
|
354
|
+
expiresAt = Date.now() + options * 1000;
|
|
355
|
+
}
|
|
356
|
+
else if (typeof options === 'object' && options?.TTLSeconds && options.TTLSeconds > 0) {
|
|
357
|
+
expiresAt = Date.now() + options.TTLSeconds * 1000;
|
|
358
|
+
}
|
|
359
|
+
const existing = this._l1Map.get(l1Key);
|
|
360
|
+
if (existing) {
|
|
361
|
+
this._currentL1Bytes -= existing.SizeBytes;
|
|
362
|
+
this._l1Map.delete(l1Key);
|
|
363
|
+
}
|
|
364
|
+
this._currentL1Bytes += sizeBytes;
|
|
365
|
+
this._l1Map.set(l1Key, {
|
|
366
|
+
Value: frozen,
|
|
367
|
+
SizeBytes: sizeBytes,
|
|
368
|
+
ExpiresAt: expiresAt,
|
|
369
|
+
Category: category,
|
|
370
|
+
Key: key,
|
|
371
|
+
});
|
|
372
|
+
this.evictIfNeeded();
|
|
373
|
+
}
|
|
374
|
+
deleteL1Entry(l1Key) {
|
|
375
|
+
const entry = this._l1Map.get(l1Key);
|
|
376
|
+
if (entry) {
|
|
377
|
+
this._l1Map.delete(l1Key);
|
|
378
|
+
this._currentL1Bytes -= entry.SizeBytes;
|
|
379
|
+
if (this._currentL1Bytes < 0) {
|
|
380
|
+
this._currentL1Bytes = 0;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
clearCategoryInL1(category) {
|
|
385
|
+
for (const [l1Key, entry] of Array.from(this._l1Map.entries())) {
|
|
386
|
+
if (entry.Category === category) {
|
|
387
|
+
this.deleteL1Entry(l1Key);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
evictIfNeeded() {
|
|
392
|
+
if (this._currentL1Bytes <= this._maxL1Bytes) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
for (const [k, entry] of this._l1Map.entries()) {
|
|
396
|
+
this._l1Map.delete(k);
|
|
397
|
+
this._currentL1Bytes -= entry.SizeBytes;
|
|
398
|
+
if (this._currentL1Bytes <= this._maxL1Bytes) {
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (this._currentL1Bytes < 0) {
|
|
403
|
+
this._currentL1Bytes = 0;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
handleRedisCacheChanged(event) {
|
|
407
|
+
if (event.Action === 'category_cleared') {
|
|
408
|
+
this.clearCategoryInL1(event.Category);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (event.Action === 'removed' || event.Action === 'set') {
|
|
412
|
+
const l1Key = this.buildL1Key(event.CacheKey, event.Category);
|
|
413
|
+
this.deleteL1Entry(l1Key);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (event.Action === 'row_delta' && event.Category === 'RunViewCache' && event.Data) {
|
|
417
|
+
this.applyRowDeltaToL1(event.CacheKey, event.Data);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
applyRowDeltaToL1(cacheKey, deltaJson) {
|
|
422
|
+
const l1Key = this.buildL1Key(cacheKey, 'RunViewCache');
|
|
423
|
+
const entry = this._l1Map.get(l1Key);
|
|
424
|
+
if (!entry) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
try {
|
|
428
|
+
const delta = JSON.parse(deltaJson);
|
|
429
|
+
const currentData = entry.Value;
|
|
430
|
+
if (typeof currentData !== 'object' || currentData === null || !Array.isArray(currentData.results)) {
|
|
431
|
+
this.deleteL1Entry(l1Key);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
// Schema hash verification: if both provide a schemaHash and they differ, evict
|
|
435
|
+
if (delta.schemaHash && currentData.schemaHash && delta.schemaHash !== currentData.schemaHash) {
|
|
436
|
+
this.deleteL1Entry(l1Key);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
const pkFields = delta.primaryKeyFields;
|
|
440
|
+
if (!Array.isArray(pkFields) || pkFields.length === 0) {
|
|
441
|
+
this.deleteL1Entry(l1Key);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
// Copy-on-Write: shallow copy results array
|
|
445
|
+
let nextResults = currentData.results.slice();
|
|
446
|
+
// 1. Process deletedPrimaryKeys
|
|
447
|
+
if (Array.isArray(delta.deletedPrimaryKeys)) {
|
|
448
|
+
for (const delPk of delta.deletedPrimaryKeys) {
|
|
449
|
+
nextResults = nextResults.filter(row => !rowsMatch(row, delPk, pkFields));
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
// 2. Process upsertedRows
|
|
453
|
+
if (Array.isArray(delta.upsertedRows)) {
|
|
454
|
+
for (const rawRow of delta.upsertedRows) {
|
|
455
|
+
// Deep freeze only the mutated row
|
|
456
|
+
const frozenRow = DeepFreeze(rawRow);
|
|
457
|
+
const idx = nextResults.findIndex(row => rowsMatch(row, frozenRow, pkFields));
|
|
458
|
+
if (idx >= 0) {
|
|
459
|
+
nextResults[idx] = frozenRow;
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
nextResults.push(frozenRow);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
// 3. Invariant check: postRowCount must equal delta.rowCount
|
|
467
|
+
if (nextResults.length !== delta.rowCount) {
|
|
468
|
+
// Drift detected; evict slot so next read re-hydrates from Redis L2
|
|
469
|
+
this.deleteL1Entry(l1Key);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
// 4. Construct updated frozen envelope
|
|
473
|
+
const updatedData = {
|
|
474
|
+
...currentData,
|
|
475
|
+
results: Object.freeze(nextResults),
|
|
476
|
+
maxUpdatedAt: delta.maxUpdatedAt,
|
|
477
|
+
totalRowCount: delta.totalRowCount,
|
|
478
|
+
};
|
|
479
|
+
if (delta.schemaHash !== undefined) {
|
|
480
|
+
updatedData.schemaHash = delta.schemaHash;
|
|
481
|
+
}
|
|
482
|
+
const frozenUpdated = Object.freeze(updatedData);
|
|
483
|
+
// Update in-place in L1
|
|
484
|
+
const oldSize = entry.SizeBytes;
|
|
485
|
+
const newSize = estimateSizeBytes(frozenUpdated);
|
|
486
|
+
entry.Value = frozenUpdated;
|
|
487
|
+
entry.SizeBytes = newSize;
|
|
488
|
+
this._currentL1Bytes = this._currentL1Bytes - oldSize + newSize;
|
|
489
|
+
this.evictIfNeeded();
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
LogError(`Failed to apply row delta to L1 for key "${cacheKey}": ${err.message}`);
|
|
493
|
+
this.deleteL1Entry(l1Key);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
//# sourceMappingURL=TwoTierCacheStorageProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TwoTierCacheStorageProvider.js","sourceRoot":"","sources":["../src/TwoTierCacheStorageProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAmCpD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAI,GAAM,EAAE,UAA2B,IAAI,OAAO,EAAE;IAC1E,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,GAAG,CAAC;IACf,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,GAAa,CAAC,EAAE,CAAC;QACrD,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,GAAa,CAAC,CAAC;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Q,CAAC,4CAA4C,QAAQ,MAAO,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7F,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
* });
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export { RedisLocalStorageProvider, RedisProviderConfig, CachePublishMode, ChannelMessageHandler, KeyLockTimeoutError, KeyLockLostError } from './RedisLocalStorageProvider.js';
|
|
22
|
+
export { RedisLocalStorageProvider, RedisProviderConfig, CachePublishMode, ChannelMessageHandler, KeyLockTimeoutError, KeyLockLostError, ExtendedWriteOptions, } from './RedisLocalStorageProvider.js';
|
|
23
|
+
export { TwoTierCacheStorageProvider, TwoTierCacheConfig, DeepFreeze, } from './TwoTierCacheStorageProvider.js';
|
|
23
24
|
export { ClearSharedCacheCategories, SHARED_CACHE_WRITE_CATEGORIES, SharedCacheCategoryClear, SharedCacheClearOptions, } from './SharedCacheClear.js';
|
|
24
25
|
export type { CacheChangedEvent } from '@memberjunction/core';
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACH,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,2BAA2B,EAC3B,kBAAkB,EAClB,UAAU,GACb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,0BAA0B,EAC1B,6BAA6B,EAC7B,wBAAwB,EACxB,uBAAuB,GAC1B,MAAM,uBAAuB,CAAC;AAI/B,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* });
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export { RedisLocalStorageProvider, KeyLockTimeoutError, KeyLockLostError } from './RedisLocalStorageProvider.js';
|
|
22
|
+
export { RedisLocalStorageProvider, KeyLockTimeoutError, KeyLockLostError, } from './RedisLocalStorageProvider.js';
|
|
23
|
+
export { TwoTierCacheStorageProvider, DeepFreeze, } from './TwoTierCacheStorageProvider.js';
|
|
23
24
|
export { ClearSharedCacheCategories, SHARED_CACHE_WRITE_CATEGORIES, } from './SharedCacheClear.js';
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACH,yBAAyB,EAIzB,mBAAmB,EACnB,gBAAgB,GAEnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,2BAA2B,EAE3B,UAAU,GACb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,0BAA0B,EAC1B,6BAA6B,GAGhC,MAAM,uBAAuB,CAAC"}
|