lakutata 2.0.39 → 2.0.40
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/com/cacher.cjs +17 -19
- package/com/cacher.d.ts +16 -6
- package/com/cacher.mjs +1 -1
- package/package.json +1 -1
- package/src/components/cacher/Cacher.cjs +195 -178
- package/src/components/cacher/Cacher.mjs +182 -165
- package/src/components/cacher/interfaces/CacherOptions.cjs +1 -0
- package/src/components/cacher/interfaces/CacherOptions.mjs +1 -0
- package/vendor/Package.18.cjs +212 -218
- package/vendor/Package.18.mjs +204 -210
- package/src/components/cacher/options/CacherOptions.cjs +0 -95
- package/src/components/cacher/options/CacherOptions.mjs +0 -89
|
@@ -10,131 +10,127 @@ const r = require("events");
|
|
|
10
10
|
|
|
11
11
|
const t = require("../../../vendor/Package.65.cjs");
|
|
12
12
|
|
|
13
|
-
const s = require("
|
|
14
|
-
|
|
15
|
-
const i = require("../../lib/core/Component.cjs");
|
|
13
|
+
const s = require("../../lib/core/Component.cjs");
|
|
16
14
|
|
|
17
15
|
const c = require("../../decorators/di/Configurable.cjs");
|
|
18
16
|
|
|
19
|
-
const
|
|
17
|
+
const i = require("../../lib/helpers/As.cjs");
|
|
20
18
|
|
|
21
|
-
const
|
|
19
|
+
const a = require("./adapters/CreateFileCacheAdapter.cjs");
|
|
22
20
|
|
|
23
|
-
const
|
|
21
|
+
const n = require("./adapters/CreateRedisCacheAdapter.cjs");
|
|
24
22
|
|
|
25
|
-
const
|
|
23
|
+
const o = require("./adapters/CreateMemcacheCacheAdapter.cjs");
|
|
26
24
|
|
|
27
25
|
const l = require("./adapters/CreateMongoCacheAdapter.cjs");
|
|
28
26
|
|
|
29
|
-
const
|
|
27
|
+
const u = require("./adapters/CreateSqliteCacheAdapter.cjs");
|
|
30
28
|
|
|
31
|
-
const
|
|
29
|
+
const h = require("./adapters/CreatePostgresCacheAdapter.cjs");
|
|
32
30
|
|
|
33
|
-
const
|
|
31
|
+
const d = require("./adapters/CreateMysqlCacheAdapter.cjs");
|
|
34
32
|
|
|
35
|
-
require("
|
|
33
|
+
const p = require("../../../vendor/Package.2.cjs");
|
|
36
34
|
|
|
37
|
-
require("
|
|
35
|
+
const m = require("./options/FileCacheOptions.cjs");
|
|
38
36
|
|
|
39
|
-
require("
|
|
37
|
+
const y = require("./options/RedisCacheOptions.cjs");
|
|
40
38
|
|
|
41
|
-
require("
|
|
39
|
+
const j = require("./options/MemcacheCacheOptions.cjs");
|
|
42
40
|
|
|
43
|
-
require("
|
|
41
|
+
const q = require("./options/MongoCacheOptions.cjs");
|
|
44
42
|
|
|
45
|
-
require("
|
|
43
|
+
const f = require("./options/SqliteCacheOptions.cjs");
|
|
46
44
|
|
|
47
|
-
require("
|
|
45
|
+
const b = require("./options/PostgresCacheOptions.cjs");
|
|
48
46
|
|
|
49
|
-
require("
|
|
50
|
-
|
|
51
|
-
require("url");
|
|
47
|
+
const g = require("./options/MysqlCacheOptions.cjs");
|
|
52
48
|
|
|
53
|
-
require("
|
|
49
|
+
require("buffer");
|
|
54
50
|
|
|
55
|
-
require("
|
|
51
|
+
require("../../../vendor/Package.3.cjs");
|
|
56
52
|
|
|
57
|
-
require("../../
|
|
53
|
+
require("../../lib/base/async-constructor/AsyncConstructor.cjs");
|
|
58
54
|
|
|
59
|
-
require("../../lib/base/
|
|
55
|
+
require("../../lib/base/async-constructor/Append.cjs");
|
|
60
56
|
|
|
61
|
-
require("../../lib/
|
|
57
|
+
require("../../lib/helpers/IsPromiseLike.cjs");
|
|
62
58
|
|
|
63
|
-
require("
|
|
59
|
+
require("../../lib/helpers/IsPromise.cjs");
|
|
64
60
|
|
|
65
|
-
require("
|
|
61
|
+
require("util/types");
|
|
66
62
|
|
|
67
|
-
require("../../
|
|
63
|
+
require("../../decorators/di/Lifetime.cjs");
|
|
68
64
|
|
|
69
|
-
require("../../lib/
|
|
65
|
+
require("../../lib/base/internal/ObjectLifetime.cjs");
|
|
70
66
|
|
|
71
|
-
require("../../
|
|
67
|
+
require("../../constants/DIMetadataKey.cjs");
|
|
72
68
|
|
|
73
|
-
require("
|
|
69
|
+
require("../../../vendor/Package.4.cjs");
|
|
74
70
|
|
|
75
|
-
require("../../../vendor/Package.
|
|
71
|
+
require("../../../vendor/Package.5.cjs");
|
|
76
72
|
|
|
77
|
-
require("../../
|
|
73
|
+
require("../../exceptions/di/LifetimeLockedException.cjs");
|
|
78
74
|
|
|
79
|
-
require("../../lib/
|
|
75
|
+
require("../../lib/base/abstracts/Exception.cjs");
|
|
80
76
|
|
|
81
|
-
require("../../
|
|
77
|
+
require("../../lib/base/internal/BasicInfo.cjs");
|
|
82
78
|
|
|
83
|
-
require("
|
|
79
|
+
require("../../../vendor/Package.6.cjs");
|
|
84
80
|
|
|
85
|
-
require("
|
|
81
|
+
require("../../../vendor/Package.7.cjs");
|
|
86
82
|
|
|
87
|
-
require("../../lib/
|
|
83
|
+
require("../../lib/base/internal/ThrowWarning.cjs");
|
|
88
84
|
|
|
89
|
-
require("../../lib/helpers/
|
|
85
|
+
require("../../lib/helpers/Templating.cjs");
|
|
90
86
|
|
|
91
|
-
require("../../
|
|
87
|
+
require("../../lib/base/internal/CamelCase.cjs");
|
|
92
88
|
|
|
93
|
-
require("
|
|
89
|
+
require("../../lib/helpers/NoCase.cjs");
|
|
94
90
|
|
|
95
|
-
require("
|
|
91
|
+
require("../../exceptions/MethodNotFoundException.cjs");
|
|
96
92
|
|
|
97
|
-
require("
|
|
93
|
+
require("../../lib/ioc/DependencyInjectionContainer.cjs");
|
|
98
94
|
|
|
99
|
-
require("
|
|
95
|
+
require("util");
|
|
100
96
|
|
|
101
|
-
require("
|
|
97
|
+
require("../../lib/ioc/Errors.cjs");
|
|
102
98
|
|
|
103
|
-
require("
|
|
99
|
+
require("../../exceptions/di/DependencyInjectionException.cjs");
|
|
104
100
|
|
|
105
|
-
require("
|
|
101
|
+
require("../../lib/base/internal/ConstructorSymbol.cjs");
|
|
106
102
|
|
|
107
|
-
require("
|
|
103
|
+
require("node:crypto");
|
|
108
104
|
|
|
109
|
-
require("../../lib/base/
|
|
105
|
+
require("../../lib/base/internal/DataValidator.cjs");
|
|
110
106
|
|
|
111
|
-
require("
|
|
107
|
+
require("node:util/types");
|
|
112
108
|
|
|
113
|
-
require("../../lib/
|
|
109
|
+
require("../../lib/validation/VLD.cjs");
|
|
114
110
|
|
|
115
|
-
require("
|
|
111
|
+
require("../../../vendor/Package.11.cjs");
|
|
116
112
|
|
|
117
|
-
require("
|
|
113
|
+
require("url");
|
|
118
114
|
|
|
119
|
-
require("
|
|
115
|
+
require("../../../vendor/Package.10.cjs");
|
|
120
116
|
|
|
121
|
-
require("../../
|
|
117
|
+
require("../../exceptions/dto/InvalidValueException.cjs");
|
|
122
118
|
|
|
123
|
-
require("
|
|
119
|
+
require("../../../vendor/Package.9.cjs");
|
|
124
120
|
|
|
125
|
-
require("../../
|
|
121
|
+
require("../../lib/helpers/IsHtml.cjs");
|
|
126
122
|
|
|
127
|
-
require("../../
|
|
123
|
+
require("../../lib/helpers/IsXML.cjs");
|
|
128
124
|
|
|
129
|
-
require("../../
|
|
125
|
+
require("../../constants/DTOMetadataKey.cjs");
|
|
130
126
|
|
|
131
|
-
require("../../lib/
|
|
127
|
+
require("../../lib/helpers/ObjectConstructor.cjs");
|
|
132
128
|
|
|
133
|
-
require("../../
|
|
129
|
+
require("../../lib/helpers/ObjectParentConstructors.cjs");
|
|
134
130
|
|
|
135
|
-
require("../../lib/
|
|
131
|
+
require("../../lib/helpers/ObjectParentConstructor.cjs");
|
|
136
132
|
|
|
137
|
-
require("
|
|
133
|
+
require("../../lib/helpers/ObjectPrototype.cjs");
|
|
138
134
|
|
|
139
135
|
require("../../lib/ioc/InjectionMode.cjs");
|
|
140
136
|
|
|
@@ -174,6 +170,8 @@ require("../../lib/base/internal/ObjectContainer.cjs");
|
|
|
174
170
|
|
|
175
171
|
require("../../lib/helpers/DevNull.cjs");
|
|
176
172
|
|
|
173
|
+
require("../../decorators/dto/Expect.cjs");
|
|
174
|
+
|
|
177
175
|
require("../../decorators/dto/IndexSignature.cjs");
|
|
178
176
|
|
|
179
177
|
require("../../decorators/dto/Accept.cjs");
|
|
@@ -208,55 +206,55 @@ require("./exceptions/CacheDriverNotFoundException.cjs");
|
|
|
208
206
|
|
|
209
207
|
require("../../lib/helpers/URLBuilder.cjs");
|
|
210
208
|
|
|
211
|
-
const
|
|
209
|
+
const C = e => e && e.__esModule ? e : {
|
|
212
210
|
default: e
|
|
213
211
|
};
|
|
214
212
|
|
|
215
|
-
const
|
|
213
|
+
const v = C(r);
|
|
216
214
|
|
|
217
|
-
var
|
|
215
|
+
var k = new Map;
|
|
218
216
|
|
|
219
|
-
function
|
|
220
|
-
return
|
|
217
|
+
function P(e) {
|
|
218
|
+
return k.has(e);
|
|
221
219
|
}
|
|
222
220
|
|
|
223
|
-
function
|
|
224
|
-
|
|
221
|
+
function w(e) {
|
|
222
|
+
k.set(e, []);
|
|
225
223
|
}
|
|
226
224
|
|
|
227
|
-
function
|
|
228
|
-
|
|
225
|
+
function O(e) {
|
|
226
|
+
k.delete(e);
|
|
229
227
|
}
|
|
230
228
|
|
|
231
|
-
function
|
|
232
|
-
const t =
|
|
229
|
+
function _(e, r) {
|
|
230
|
+
const t = A(e);
|
|
233
231
|
t.push(r);
|
|
234
|
-
|
|
232
|
+
k.set(e, t);
|
|
235
233
|
}
|
|
236
234
|
|
|
237
|
-
function
|
|
238
|
-
return
|
|
235
|
+
function A(e) {
|
|
236
|
+
return k.get(e) ?? [];
|
|
239
237
|
}
|
|
240
238
|
|
|
241
|
-
async function
|
|
239
|
+
async function S(e) {
|
|
242
240
|
return new Promise(((r, t) => {
|
|
243
241
|
const s = {
|
|
244
242
|
resolve: r,
|
|
245
243
|
reject: t
|
|
246
244
|
};
|
|
247
|
-
|
|
245
|
+
_(e, s);
|
|
248
246
|
}));
|
|
249
247
|
}
|
|
250
248
|
|
|
251
|
-
function
|
|
252
|
-
const r =
|
|
253
|
-
|
|
249
|
+
function M(e) {
|
|
250
|
+
const r = A(e);
|
|
251
|
+
O(e);
|
|
254
252
|
return r;
|
|
255
253
|
}
|
|
256
254
|
|
|
257
|
-
function
|
|
255
|
+
function x(e) {
|
|
258
256
|
const {key: r, error: t, result: s} = e;
|
|
259
|
-
for (const e of
|
|
257
|
+
for (const e of M(r)) {
|
|
260
258
|
if (t) {
|
|
261
259
|
e.reject(t);
|
|
262
260
|
} else {
|
|
@@ -265,40 +263,40 @@ function k(e) {
|
|
|
265
263
|
}
|
|
266
264
|
}
|
|
267
265
|
|
|
268
|
-
async function
|
|
269
|
-
if (!
|
|
270
|
-
|
|
266
|
+
async function I(e, r) {
|
|
267
|
+
if (!P(e)) {
|
|
268
|
+
w(e);
|
|
271
269
|
try {
|
|
272
270
|
const t = await Promise.resolve(r());
|
|
273
|
-
|
|
271
|
+
x({
|
|
274
272
|
key: e,
|
|
275
273
|
result: t
|
|
276
274
|
});
|
|
277
275
|
return t;
|
|
278
276
|
} catch (r) {
|
|
279
|
-
|
|
277
|
+
x({
|
|
280
278
|
key: e,
|
|
281
279
|
error: r
|
|
282
280
|
});
|
|
283
281
|
throw r;
|
|
284
282
|
}
|
|
285
283
|
}
|
|
286
|
-
return
|
|
284
|
+
return S(e);
|
|
287
285
|
}
|
|
288
286
|
|
|
289
|
-
function
|
|
287
|
+
function T(e) {
|
|
290
288
|
return e !== null && typeof e === "object" && !Array.isArray(e);
|
|
291
289
|
}
|
|
292
290
|
|
|
293
|
-
function
|
|
291
|
+
function D(e, ...r) {
|
|
294
292
|
return typeof e === "function" ? e(...r) : e;
|
|
295
293
|
}
|
|
296
294
|
|
|
297
|
-
function
|
|
295
|
+
function L(e, r) {
|
|
298
296
|
return typeof e === "number" && typeof r === "number" ? e < r : false;
|
|
299
297
|
}
|
|
300
298
|
|
|
301
|
-
var
|
|
299
|
+
var B = class {
|
|
302
300
|
opts;
|
|
303
301
|
namespace;
|
|
304
302
|
_cache;
|
|
@@ -346,19 +344,19 @@ var O = class {
|
|
|
346
344
|
}
|
|
347
345
|
};
|
|
348
346
|
|
|
349
|
-
var
|
|
350
|
-
const r = new
|
|
347
|
+
var E = e => {
|
|
348
|
+
const r = new v.default;
|
|
351
349
|
const s = new t.Keyv;
|
|
352
350
|
s.serialize = void 0;
|
|
353
351
|
s.deserialize = void 0;
|
|
354
|
-
const
|
|
355
|
-
const
|
|
352
|
+
const c = e?.stores?.length ? e.stores : [ s ];
|
|
353
|
+
const i = e?.nonBlocking ?? false;
|
|
356
354
|
const a = e?.cacheId ?? Math.random().toString(36).slice(2);
|
|
357
355
|
const n = async e => {
|
|
358
356
|
let t;
|
|
359
|
-
if (
|
|
357
|
+
if (i) {
|
|
360
358
|
try {
|
|
361
|
-
t = await Promise.race(
|
|
359
|
+
t = await Promise.race(c.map((async r => r.get(e))));
|
|
362
360
|
if (t === void 0) {
|
|
363
361
|
return void 0;
|
|
364
362
|
}
|
|
@@ -369,11 +367,11 @@ var I = e => {
|
|
|
369
367
|
});
|
|
370
368
|
}
|
|
371
369
|
} else {
|
|
372
|
-
for (const s of
|
|
370
|
+
for (const s of c) {
|
|
373
371
|
try {
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
376
|
-
t =
|
|
372
|
+
const c = await s.get(e);
|
|
373
|
+
if (c !== void 0) {
|
|
374
|
+
t = c;
|
|
377
375
|
r.emit("get", {
|
|
378
376
|
key: e,
|
|
379
377
|
value: t
|
|
@@ -398,11 +396,11 @@ var I = e => {
|
|
|
398
396
|
}
|
|
399
397
|
return r;
|
|
400
398
|
};
|
|
401
|
-
const
|
|
399
|
+
const l = async e => {
|
|
402
400
|
let t;
|
|
403
|
-
if (
|
|
401
|
+
if (i) {
|
|
404
402
|
try {
|
|
405
|
-
t = await Promise.race(
|
|
403
|
+
t = await Promise.race(c.map((async r => r.get(e, {
|
|
406
404
|
raw: true
|
|
407
405
|
}))));
|
|
408
406
|
if (t === void 0) {
|
|
@@ -415,13 +413,13 @@ var I = e => {
|
|
|
415
413
|
});
|
|
416
414
|
}
|
|
417
415
|
} else {
|
|
418
|
-
for (const s of
|
|
416
|
+
for (const s of c) {
|
|
419
417
|
try {
|
|
420
|
-
const
|
|
418
|
+
const c = await s.get(e, {
|
|
421
419
|
raw: true
|
|
422
420
|
});
|
|
423
|
-
if (
|
|
424
|
-
t =
|
|
421
|
+
if (c !== void 0) {
|
|
422
|
+
t = c;
|
|
425
423
|
r.emit("ttl", {
|
|
426
424
|
key: e,
|
|
427
425
|
value: t
|
|
@@ -441,26 +439,26 @@ var I = e => {
|
|
|
441
439
|
}
|
|
442
440
|
return void 0;
|
|
443
441
|
};
|
|
444
|
-
const
|
|
442
|
+
const u = async (t, s, c, a) => {
|
|
445
443
|
try {
|
|
446
|
-
if (
|
|
447
|
-
Promise.all(t.map((async r => r.set(s,
|
|
444
|
+
if (i) {
|
|
445
|
+
Promise.all(t.map((async r => r.set(s, c, a ?? e?.ttl))));
|
|
448
446
|
r.emit("set", {
|
|
449
447
|
key: s,
|
|
450
|
-
value:
|
|
448
|
+
value: c
|
|
451
449
|
});
|
|
452
|
-
return
|
|
450
|
+
return c;
|
|
453
451
|
}
|
|
454
|
-
await Promise.all(t.map((async r => r.set(s,
|
|
452
|
+
await Promise.all(t.map((async r => r.set(s, c, a ?? e?.ttl))));
|
|
455
453
|
r.emit("set", {
|
|
456
454
|
key: s,
|
|
457
|
-
value:
|
|
455
|
+
value: c
|
|
458
456
|
});
|
|
459
|
-
return
|
|
457
|
+
return c;
|
|
460
458
|
} catch (e) {
|
|
461
459
|
r.emit("set", {
|
|
462
460
|
key: s,
|
|
463
|
-
value:
|
|
461
|
+
value: c,
|
|
464
462
|
error: e
|
|
465
463
|
});
|
|
466
464
|
return Promise.reject(e);
|
|
@@ -477,7 +475,7 @@ var I = e => {
|
|
|
477
475
|
for (const r of t) {
|
|
478
476
|
s.push(...e.map((async e => e.set(r.key, r.value, r.ttl))));
|
|
479
477
|
}
|
|
480
|
-
if (
|
|
478
|
+
if (i) {
|
|
481
479
|
Promise.all(s);
|
|
482
480
|
r.emit("mset", {
|
|
483
481
|
list: t
|
|
@@ -499,14 +497,14 @@ var I = e => {
|
|
|
499
497
|
};
|
|
500
498
|
const d = async e => {
|
|
501
499
|
try {
|
|
502
|
-
if (
|
|
503
|
-
Promise.all(
|
|
500
|
+
if (i) {
|
|
501
|
+
Promise.all(c.map((async r => r.delete(e))));
|
|
504
502
|
r.emit("del", {
|
|
505
503
|
key: e
|
|
506
504
|
});
|
|
507
505
|
return true;
|
|
508
506
|
}
|
|
509
|
-
await Promise.all(
|
|
507
|
+
await Promise.all(c.map((async r => r.delete(e))));
|
|
510
508
|
r.emit("del", {
|
|
511
509
|
key: e
|
|
512
510
|
});
|
|
@@ -523,9 +521,9 @@ var I = e => {
|
|
|
523
521
|
try {
|
|
524
522
|
const t = [];
|
|
525
523
|
for (const r of e) {
|
|
526
|
-
t.push(...
|
|
524
|
+
t.push(...c.map((async e => e.delete(r))));
|
|
527
525
|
}
|
|
528
|
-
if (
|
|
526
|
+
if (i) {
|
|
529
527
|
Promise.all(t);
|
|
530
528
|
r.emit("mdel", {
|
|
531
529
|
keys: e
|
|
@@ -545,14 +543,14 @@ var I = e => {
|
|
|
545
543
|
return Promise.reject(t);
|
|
546
544
|
}
|
|
547
545
|
};
|
|
548
|
-
const
|
|
546
|
+
const m = async () => {
|
|
549
547
|
try {
|
|
550
|
-
if (
|
|
551
|
-
Promise.all(
|
|
548
|
+
if (i) {
|
|
549
|
+
Promise.all(c.map((async e => e.clear())));
|
|
552
550
|
r.emit("clear");
|
|
553
551
|
return true;
|
|
554
552
|
}
|
|
555
|
-
await Promise.all(
|
|
553
|
+
await Promise.all(c.map((async e => e.clear())));
|
|
556
554
|
r.emit("clear");
|
|
557
555
|
return true;
|
|
558
556
|
} catch (e) {
|
|
@@ -560,24 +558,24 @@ var I = e => {
|
|
|
560
558
|
return Promise.reject(e);
|
|
561
559
|
}
|
|
562
560
|
};
|
|
563
|
-
const
|
|
561
|
+
const y = async (t, s, i, n) => I(`${a}::${t}`, (async () => {
|
|
564
562
|
let o;
|
|
565
|
-
let
|
|
563
|
+
let l;
|
|
566
564
|
let h = 0;
|
|
567
565
|
let d;
|
|
568
|
-
const {ttl: p, refreshThreshold:
|
|
569
|
-
ttl:
|
|
566
|
+
const {ttl: p, refreshThreshold: m, raw: y} = T(i) ? i : {
|
|
567
|
+
ttl: i,
|
|
570
568
|
refreshThreshold: n
|
|
571
569
|
};
|
|
572
|
-
const
|
|
573
|
-
for (;h <
|
|
570
|
+
const j = r => D(p, r) ?? e?.ttl;
|
|
571
|
+
for (;h < c.length; h++) {
|
|
574
572
|
try {
|
|
575
|
-
const e = await
|
|
573
|
+
const e = await c[h].get(t, {
|
|
576
574
|
raw: true
|
|
577
575
|
});
|
|
578
576
|
if (e !== void 0) {
|
|
579
577
|
o = e.value;
|
|
580
|
-
|
|
578
|
+
l = e;
|
|
581
579
|
if (typeof e.expires === "number") {
|
|
582
580
|
d = Math.max(0, e.expires - Date.now());
|
|
583
581
|
}
|
|
@@ -587,18 +585,18 @@ var I = e => {
|
|
|
587
585
|
}
|
|
588
586
|
if (o === void 0) {
|
|
589
587
|
const e = await s();
|
|
590
|
-
const r =
|
|
591
|
-
await
|
|
592
|
-
return
|
|
588
|
+
const r = j(e);
|
|
589
|
+
await u(c, t, e, r);
|
|
590
|
+
return y ? {
|
|
593
591
|
value: e,
|
|
594
592
|
expires: Date.now() + r
|
|
595
593
|
} : e;
|
|
596
594
|
}
|
|
597
|
-
const q =
|
|
595
|
+
const q = L(d, D(m, o) ?? e?.refreshThreshold);
|
|
598
596
|
if (q) {
|
|
599
|
-
|
|
597
|
+
I(`+++${a}__${t}`, s).then((async s => {
|
|
600
598
|
try {
|
|
601
|
-
await
|
|
599
|
+
await u(e?.refreshAllStores ? c : c.slice(0, h + 1), t, s, j(s));
|
|
602
600
|
r.emit("refresh", {
|
|
603
601
|
key: t,
|
|
604
602
|
value: s
|
|
@@ -619,77 +617,86 @@ var I = e => {
|
|
|
619
617
|
}));
|
|
620
618
|
}
|
|
621
619
|
if (!q && h > 0) {
|
|
622
|
-
await
|
|
620
|
+
await u(c.slice(0, h), t, o, j(o));
|
|
623
621
|
}
|
|
624
|
-
return
|
|
622
|
+
return y ? l : o;
|
|
625
623
|
}));
|
|
626
|
-
const
|
|
627
|
-
const
|
|
628
|
-
const
|
|
624
|
+
const j = (e, t) => r.addListener(e, t);
|
|
625
|
+
const q = (e, t) => r.removeListener(e, t);
|
|
626
|
+
const f = async () => {
|
|
629
627
|
try {
|
|
630
|
-
await Promise.all(
|
|
628
|
+
await Promise.all(c.map((async e => e.disconnect())));
|
|
631
629
|
} catch (e) {
|
|
632
630
|
return Promise.reject(e);
|
|
633
631
|
}
|
|
634
632
|
};
|
|
635
|
-
const
|
|
633
|
+
const b = () => a;
|
|
636
634
|
return {
|
|
637
635
|
get: n,
|
|
638
636
|
mget: o,
|
|
639
|
-
ttl:
|
|
640
|
-
set: async (e, r, t) =>
|
|
641
|
-
mset: async e => h(
|
|
637
|
+
ttl: l,
|
|
638
|
+
set: async (e, r, t) => u(c, e, r, t),
|
|
639
|
+
mset: async e => h(c, e),
|
|
642
640
|
del: d,
|
|
643
641
|
mdel: p,
|
|
644
|
-
clear:
|
|
645
|
-
wrap:
|
|
646
|
-
on:
|
|
647
|
-
off:
|
|
648
|
-
disconnect:
|
|
649
|
-
cacheId:
|
|
650
|
-
stores:
|
|
642
|
+
clear: m,
|
|
643
|
+
wrap: y,
|
|
644
|
+
on: j,
|
|
645
|
+
off: q,
|
|
646
|
+
disconnect: f,
|
|
647
|
+
cacheId: b,
|
|
648
|
+
stores: c
|
|
651
649
|
};
|
|
652
650
|
};
|
|
653
651
|
|
|
654
|
-
const
|
|
652
|
+
const R = e => ({
|
|
655
653
|
class: Cacher,
|
|
656
|
-
|
|
654
|
+
stores: e?.stores,
|
|
655
|
+
ttl: e?.ttl,
|
|
656
|
+
refreshThreshold: e?.refreshThreshold,
|
|
657
|
+
refreshAllStores: e?.refreshAllStores,
|
|
658
|
+
nonBlocking: e?.nonBlocking,
|
|
659
|
+
cacheId: e?.cacheId
|
|
657
660
|
});
|
|
658
661
|
|
|
659
|
-
class Cacher extends
|
|
662
|
+
class Cacher extends s.Component {
|
|
660
663
|
async init() {
|
|
661
|
-
const e = this.
|
|
664
|
+
const e = this.stores ? Array.isArray(this.stores) ? this.stores : [ this.stores ] : [];
|
|
662
665
|
const r = await Promise.all(e.map((e => {
|
|
663
666
|
switch (e.type) {
|
|
664
667
|
case "file":
|
|
665
|
-
return
|
|
668
|
+
return a.CreateFileCacheAdapter(e);
|
|
666
669
|
|
|
667
670
|
case "redis":
|
|
668
|
-
return
|
|
671
|
+
return n.CreateRedisCacheAdapter(e);
|
|
669
672
|
|
|
670
673
|
case "memcache":
|
|
671
|
-
return
|
|
674
|
+
return o.CreateMemcacheCacheAdapter(e);
|
|
672
675
|
|
|
673
676
|
case "mongo":
|
|
674
677
|
return l.CreateMongoCacheAdapter(e);
|
|
675
678
|
|
|
676
679
|
case "sqlite":
|
|
677
|
-
return
|
|
680
|
+
return u.CreateSqliteCacheAdapter(e);
|
|
678
681
|
|
|
679
682
|
case "postgres":
|
|
680
|
-
return
|
|
683
|
+
return h.CreatePostgresCacheAdapter(e);
|
|
681
684
|
|
|
682
685
|
case "mysql":
|
|
683
|
-
return
|
|
686
|
+
return d.CreateMysqlCacheAdapter(e);
|
|
684
687
|
|
|
685
688
|
default:
|
|
686
689
|
return undefined;
|
|
687
690
|
}
|
|
688
691
|
})));
|
|
689
692
|
const t = r.filter((e => !!e));
|
|
690
|
-
this.cache =
|
|
691
|
-
|
|
692
|
-
|
|
693
|
+
this.cache = E({
|
|
694
|
+
stores: t.length ? t : undefined,
|
|
695
|
+
ttl: this.ttl,
|
|
696
|
+
refreshThreshold: this.refreshThreshold,
|
|
697
|
+
refreshAllStores: this.refreshAllStores,
|
|
698
|
+
nonBlocking: this.nonBlocking,
|
|
699
|
+
cacheId: this.cacheId
|
|
693
700
|
});
|
|
694
701
|
this.cache.on("set", (e => this.emit("set", e)));
|
|
695
702
|
this.cache.on("del", (e => this.emit("del", e)));
|
|
@@ -706,12 +713,12 @@ class Cacher extends i.Component {
|
|
|
706
713
|
return await this.cache.mset(e);
|
|
707
714
|
}
|
|
708
715
|
async get(e) {
|
|
709
|
-
return
|
|
716
|
+
return i.As(await this.cache.get(e));
|
|
710
717
|
}
|
|
711
718
|
async multipleGet(e) {
|
|
712
719
|
return await this.cache.mget(e);
|
|
713
720
|
}
|
|
714
|
-
async
|
|
721
|
+
async getTTL(e) {
|
|
715
722
|
const r = await this.cache.ttl(e);
|
|
716
723
|
if (r === undefined) return -1;
|
|
717
724
|
return r;
|
|
@@ -730,8 +737,18 @@ class Cacher extends i.Component {
|
|
|
730
737
|
}
|
|
731
738
|
}
|
|
732
739
|
|
|
733
|
-
e.__decorate([ c.Configurable(
|
|
740
|
+
e.__decorate([ c.Configurable(p.DTO.Alternatives(p.DTO.Array(p.DTO.Alternatives(m.FileCacheOptions.Schema(), y.RedisCacheOptions.Schema(), j.MemcacheCacheOptions.Schema(), q.MongoCacheOptions.Schema(), f.SqliteCacheOptions.Schema(), b.PostgresCacheOptions.Schema(), g.MysqlCacheOptions.Schema())), m.FileCacheOptions.Schema(), y.RedisCacheOptions.Schema(), j.MemcacheCacheOptions.Schema(), q.MongoCacheOptions.Schema(), f.SqliteCacheOptions.Schema(), b.PostgresCacheOptions.Schema(), g.MysqlCacheOptions.Schema()).optional()), e.__metadata("design:type", Object) ], Cacher.prototype, "stores", void 0);
|
|
741
|
+
|
|
742
|
+
e.__decorate([ c.Configurable(p.DTO.Number().positive().integer().optional()), e.__metadata("design:type", Number) ], Cacher.prototype, "ttl", void 0);
|
|
743
|
+
|
|
744
|
+
e.__decorate([ c.Configurable(p.DTO.Number().positive().integer().optional()), e.__metadata("design:type", Number) ], Cacher.prototype, "refreshThreshold", void 0);
|
|
745
|
+
|
|
746
|
+
e.__decorate([ c.Configurable(p.DTO.Boolean().optional()), e.__metadata("design:type", Boolean) ], Cacher.prototype, "refreshAllStores", void 0);
|
|
747
|
+
|
|
748
|
+
e.__decorate([ c.Configurable(p.DTO.Boolean().optional()), e.__metadata("design:type", Boolean) ], Cacher.prototype, "nonBlocking", void 0);
|
|
749
|
+
|
|
750
|
+
e.__decorate([ c.Configurable(p.DTO.String().optional()), e.__metadata("design:type", String) ], Cacher.prototype, "cacheId", void 0);
|
|
734
751
|
|
|
735
|
-
exports.BuildCacherOptions =
|
|
752
|
+
exports.BuildCacherOptions = R;
|
|
736
753
|
|
|
737
754
|
exports.Cacher = Cacher;
|