lakutata 2.0.39 → 2.0.41
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 +184 -195
- package/vendor/Package.18.mjs +176 -187
- package/src/components/cacher/options/CacherOptions.cjs +0 -95
- package/src/components/cacher/options/CacherOptions.mjs +0 -89
|
@@ -4,131 +4,127 @@ import r from "events";
|
|
|
4
4
|
|
|
5
5
|
import { K as s } from "../../../vendor/Package.65.mjs";
|
|
6
6
|
|
|
7
|
-
import { CacherOptions as i } from "./options/CacherOptions.mjs";
|
|
8
|
-
|
|
9
7
|
import { Component as o } from "../../lib/core/Component.mjs";
|
|
10
8
|
|
|
11
|
-
import { Configurable as
|
|
9
|
+
import { Configurable as i } from "../../decorators/di/Configurable.mjs";
|
|
12
10
|
|
|
13
|
-
import { As as
|
|
11
|
+
import { As as a } from "../../lib/helpers/As.mjs";
|
|
14
12
|
|
|
15
|
-
import { CreateFileCacheAdapter as
|
|
13
|
+
import { CreateFileCacheAdapter as n } from "./adapters/CreateFileCacheAdapter.mjs";
|
|
16
14
|
|
|
17
|
-
import { CreateRedisCacheAdapter as
|
|
15
|
+
import { CreateRedisCacheAdapter as c } from "./adapters/CreateRedisCacheAdapter.mjs";
|
|
18
16
|
|
|
19
|
-
import { CreateMemcacheCacheAdapter as
|
|
17
|
+
import { CreateMemcacheCacheAdapter as m } from "./adapters/CreateMemcacheCacheAdapter.mjs";
|
|
20
18
|
|
|
21
|
-
import { CreateMongoCacheAdapter as
|
|
19
|
+
import { CreateMongoCacheAdapter as l } from "./adapters/CreateMongoCacheAdapter.mjs";
|
|
22
20
|
|
|
23
|
-
import { CreateSqliteCacheAdapter as
|
|
21
|
+
import { CreateSqliteCacheAdapter as p } from "./adapters/CreateSqliteCacheAdapter.mjs";
|
|
24
22
|
|
|
25
|
-
import { CreatePostgresCacheAdapter as
|
|
23
|
+
import { CreatePostgresCacheAdapter as h } from "./adapters/CreatePostgresCacheAdapter.mjs";
|
|
26
24
|
|
|
27
25
|
import { CreateMysqlCacheAdapter as d } from "./adapters/CreateMysqlCacheAdapter.mjs";
|
|
28
26
|
|
|
29
|
-
import "
|
|
27
|
+
import { D as u } from "../../../vendor/Package.2.mjs";
|
|
30
28
|
|
|
31
|
-
import "
|
|
29
|
+
import { FileCacheOptions as y } from "./options/FileCacheOptions.mjs";
|
|
32
30
|
|
|
33
|
-
import "
|
|
31
|
+
import { RedisCacheOptions as f } from "./options/RedisCacheOptions.mjs";
|
|
34
32
|
|
|
35
|
-
import "
|
|
33
|
+
import { MemcacheCacheOptions as j } from "./options/MemcacheCacheOptions.mjs";
|
|
36
34
|
|
|
37
|
-
import "
|
|
38
|
-
|
|
39
|
-
import "node:util/types";
|
|
35
|
+
import { MongoCacheOptions as b } from "./options/MongoCacheOptions.mjs";
|
|
40
36
|
|
|
41
|
-
import "
|
|
37
|
+
import { SqliteCacheOptions as v } from "./options/SqliteCacheOptions.mjs";
|
|
42
38
|
|
|
43
|
-
import "
|
|
39
|
+
import { PostgresCacheOptions as g } from "./options/PostgresCacheOptions.mjs";
|
|
44
40
|
|
|
45
|
-
import "
|
|
41
|
+
import { MysqlCacheOptions as k } from "./options/MysqlCacheOptions.mjs";
|
|
46
42
|
|
|
47
|
-
import "
|
|
43
|
+
import "buffer";
|
|
48
44
|
|
|
49
|
-
import "
|
|
45
|
+
import "../../../vendor/Package.3.mjs";
|
|
50
46
|
|
|
51
|
-
import "../../
|
|
47
|
+
import "../../lib/base/async-constructor/AsyncConstructor.mjs";
|
|
52
48
|
|
|
53
|
-
import "../../lib/base/
|
|
49
|
+
import "../../lib/base/async-constructor/Append.mjs";
|
|
54
50
|
|
|
55
|
-
import "../../lib/
|
|
51
|
+
import "../../lib/helpers/IsPromiseLike.mjs";
|
|
56
52
|
|
|
57
|
-
import "
|
|
53
|
+
import "../../lib/helpers/IsPromise.mjs";
|
|
58
54
|
|
|
59
|
-
import "
|
|
55
|
+
import "util/types";
|
|
60
56
|
|
|
61
|
-
import "../../
|
|
57
|
+
import "../../decorators/di/Lifetime.mjs";
|
|
62
58
|
|
|
63
|
-
import "../../lib/
|
|
59
|
+
import "../../lib/base/internal/ObjectLifetime.mjs";
|
|
64
60
|
|
|
65
|
-
import "../../
|
|
61
|
+
import "../../constants/DIMetadataKey.mjs";
|
|
66
62
|
|
|
67
|
-
import "
|
|
63
|
+
import "../../../vendor/Package.4.mjs";
|
|
68
64
|
|
|
69
|
-
import "../../../vendor/Package.
|
|
65
|
+
import "../../../vendor/Package.5.mjs";
|
|
70
66
|
|
|
71
|
-
import "../../
|
|
67
|
+
import "../../exceptions/di/LifetimeLockedException.mjs";
|
|
72
68
|
|
|
73
|
-
import "../../lib/
|
|
69
|
+
import "../../lib/base/abstracts/Exception.mjs";
|
|
74
70
|
|
|
75
|
-
import "../../
|
|
71
|
+
import "../../lib/base/internal/BasicInfo.mjs";
|
|
76
72
|
|
|
77
|
-
import "
|
|
73
|
+
import "../../../vendor/Package.6.mjs";
|
|
78
74
|
|
|
79
|
-
import "
|
|
75
|
+
import "../../../vendor/Package.7.mjs";
|
|
80
76
|
|
|
81
|
-
import "../../lib/
|
|
77
|
+
import "../../lib/base/internal/ThrowWarning.mjs";
|
|
82
78
|
|
|
83
|
-
import "../../lib/helpers/
|
|
79
|
+
import "../../lib/helpers/Templating.mjs";
|
|
84
80
|
|
|
85
|
-
import "../../
|
|
81
|
+
import "../../lib/base/internal/CamelCase.mjs";
|
|
86
82
|
|
|
87
|
-
import "
|
|
83
|
+
import "../../lib/helpers/NoCase.mjs";
|
|
88
84
|
|
|
89
|
-
import "
|
|
85
|
+
import "../../exceptions/MethodNotFoundException.mjs";
|
|
90
86
|
|
|
91
|
-
import "
|
|
87
|
+
import "../../lib/ioc/DependencyInjectionContainer.mjs";
|
|
92
88
|
|
|
93
|
-
import "
|
|
89
|
+
import "util";
|
|
94
90
|
|
|
95
|
-
import "
|
|
91
|
+
import "../../lib/ioc/Errors.mjs";
|
|
96
92
|
|
|
97
|
-
import "
|
|
93
|
+
import "../../exceptions/di/DependencyInjectionException.mjs";
|
|
98
94
|
|
|
99
|
-
import "
|
|
95
|
+
import "../../lib/base/internal/ConstructorSymbol.mjs";
|
|
100
96
|
|
|
101
|
-
import "
|
|
97
|
+
import "node:crypto";
|
|
102
98
|
|
|
103
|
-
import "../../lib/base/
|
|
99
|
+
import "../../lib/base/internal/DataValidator.mjs";
|
|
104
100
|
|
|
105
|
-
import "
|
|
101
|
+
import "node:util/types";
|
|
106
102
|
|
|
107
|
-
import "../../lib/
|
|
103
|
+
import "../../lib/validation/VLD.mjs";
|
|
108
104
|
|
|
109
|
-
import "
|
|
105
|
+
import "../../../vendor/Package.11.mjs";
|
|
110
106
|
|
|
111
|
-
import "
|
|
107
|
+
import "url";
|
|
112
108
|
|
|
113
|
-
import "
|
|
109
|
+
import "../../../vendor/Package.10.mjs";
|
|
114
110
|
|
|
115
|
-
import "../../
|
|
111
|
+
import "../../exceptions/dto/InvalidValueException.mjs";
|
|
116
112
|
|
|
117
|
-
import "
|
|
113
|
+
import "../../../vendor/Package.9.mjs";
|
|
118
114
|
|
|
119
|
-
import "../../
|
|
115
|
+
import "../../lib/helpers/IsHtml.mjs";
|
|
120
116
|
|
|
121
|
-
import "../../
|
|
117
|
+
import "../../lib/helpers/IsXML.mjs";
|
|
122
118
|
|
|
123
|
-
import "../../
|
|
119
|
+
import "../../constants/DTOMetadataKey.mjs";
|
|
124
120
|
|
|
125
|
-
import "../../lib/
|
|
121
|
+
import "../../lib/helpers/ObjectConstructor.mjs";
|
|
126
122
|
|
|
127
|
-
import "../../
|
|
123
|
+
import "../../lib/helpers/ObjectParentConstructors.mjs";
|
|
128
124
|
|
|
129
|
-
import "../../lib/
|
|
125
|
+
import "../../lib/helpers/ObjectParentConstructor.mjs";
|
|
130
126
|
|
|
131
|
-
import "
|
|
127
|
+
import "../../lib/helpers/ObjectPrototype.mjs";
|
|
132
128
|
|
|
133
129
|
import "../../lib/ioc/InjectionMode.mjs";
|
|
134
130
|
|
|
@@ -168,6 +164,8 @@ import "../../lib/base/internal/ObjectContainer.mjs";
|
|
|
168
164
|
|
|
169
165
|
import "../../lib/helpers/DevNull.mjs";
|
|
170
166
|
|
|
167
|
+
import "../../decorators/dto/Expect.mjs";
|
|
168
|
+
|
|
171
169
|
import "../../decorators/dto/IndexSignature.mjs";
|
|
172
170
|
|
|
173
171
|
import "../../decorators/dto/Accept.mjs";
|
|
@@ -202,49 +200,49 @@ import "./exceptions/CacheDriverNotFoundException.mjs";
|
|
|
202
200
|
|
|
203
201
|
import "../../lib/helpers/URLBuilder.mjs";
|
|
204
202
|
|
|
205
|
-
var
|
|
203
|
+
var P = new Map;
|
|
206
204
|
|
|
207
|
-
function
|
|
208
|
-
return
|
|
205
|
+
function w(e) {
|
|
206
|
+
return P.has(e);
|
|
209
207
|
}
|
|
210
208
|
|
|
211
|
-
function
|
|
212
|
-
|
|
209
|
+
function C(e) {
|
|
210
|
+
P.set(e, []);
|
|
213
211
|
}
|
|
214
212
|
|
|
215
|
-
function
|
|
216
|
-
|
|
213
|
+
function S(e) {
|
|
214
|
+
P.delete(e);
|
|
217
215
|
}
|
|
218
216
|
|
|
219
|
-
function
|
|
220
|
-
const r =
|
|
217
|
+
function x(e, t) {
|
|
218
|
+
const r = A(e);
|
|
221
219
|
r.push(t);
|
|
222
|
-
|
|
220
|
+
P.set(e, r);
|
|
223
221
|
}
|
|
224
222
|
|
|
225
|
-
function
|
|
226
|
-
return
|
|
223
|
+
function A(e) {
|
|
224
|
+
return P.get(e) ?? [];
|
|
227
225
|
}
|
|
228
226
|
|
|
229
|
-
async function
|
|
227
|
+
async function I(e) {
|
|
230
228
|
return new Promise(((t, r) => {
|
|
231
229
|
const s = {
|
|
232
230
|
resolve: t,
|
|
233
231
|
reject: r
|
|
234
232
|
};
|
|
235
|
-
|
|
233
|
+
x(e, s);
|
|
236
234
|
}));
|
|
237
235
|
}
|
|
238
236
|
|
|
239
|
-
function
|
|
240
|
-
const t =
|
|
241
|
-
|
|
237
|
+
function M(e) {
|
|
238
|
+
const t = A(e);
|
|
239
|
+
S(e);
|
|
242
240
|
return t;
|
|
243
241
|
}
|
|
244
242
|
|
|
245
|
-
function
|
|
243
|
+
function O(e) {
|
|
246
244
|
const {key: t, error: r, result: s} = e;
|
|
247
|
-
for (const e of
|
|
245
|
+
for (const e of M(t)) {
|
|
248
246
|
if (r) {
|
|
249
247
|
e.reject(r);
|
|
250
248
|
} else {
|
|
@@ -253,40 +251,40 @@ function w(e) {
|
|
|
253
251
|
}
|
|
254
252
|
}
|
|
255
253
|
|
|
256
|
-
async function
|
|
257
|
-
if (!
|
|
258
|
-
|
|
254
|
+
async function L(e, t) {
|
|
255
|
+
if (!w(e)) {
|
|
256
|
+
C(e);
|
|
259
257
|
try {
|
|
260
258
|
const r = await Promise.resolve(t());
|
|
261
|
-
|
|
259
|
+
O({
|
|
262
260
|
key: e,
|
|
263
261
|
result: r
|
|
264
262
|
});
|
|
265
263
|
return r;
|
|
266
264
|
} catch (t) {
|
|
267
|
-
|
|
265
|
+
O({
|
|
268
266
|
key: e,
|
|
269
267
|
error: t
|
|
270
268
|
});
|
|
271
269
|
throw t;
|
|
272
270
|
}
|
|
273
271
|
}
|
|
274
|
-
return
|
|
272
|
+
return I(e);
|
|
275
273
|
}
|
|
276
274
|
|
|
277
|
-
function
|
|
275
|
+
function T(e) {
|
|
278
276
|
return e !== null && typeof e === "object" && !Array.isArray(e);
|
|
279
277
|
}
|
|
280
278
|
|
|
281
|
-
function
|
|
279
|
+
function _(e, ...t) {
|
|
282
280
|
return typeof e === "function" ? e(...t) : e;
|
|
283
281
|
}
|
|
284
282
|
|
|
285
|
-
function
|
|
283
|
+
function D(e, t) {
|
|
286
284
|
return typeof e === "number" && typeof t === "number" ? e < t : false;
|
|
287
285
|
}
|
|
288
286
|
|
|
289
|
-
var
|
|
287
|
+
var E = class {
|
|
290
288
|
opts;
|
|
291
289
|
namespace;
|
|
292
290
|
_cache;
|
|
@@ -334,19 +332,19 @@ var O = class {
|
|
|
334
332
|
}
|
|
335
333
|
};
|
|
336
334
|
|
|
337
|
-
var
|
|
335
|
+
var B = e => {
|
|
338
336
|
const t = new r;
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const
|
|
337
|
+
const o = new s;
|
|
338
|
+
o.serialize = void 0;
|
|
339
|
+
o.deserialize = void 0;
|
|
340
|
+
const i = e?.stores?.length ? e.stores : [ o ];
|
|
343
341
|
const a = e?.nonBlocking ?? false;
|
|
344
342
|
const n = e?.cacheId ?? Math.random().toString(36).slice(2);
|
|
345
343
|
const c = async e => {
|
|
346
344
|
let r;
|
|
347
345
|
if (a) {
|
|
348
346
|
try {
|
|
349
|
-
r = await Promise.race(
|
|
347
|
+
r = await Promise.race(i.map((async t => t.get(e))));
|
|
350
348
|
if (r === void 0) {
|
|
351
349
|
return void 0;
|
|
352
350
|
}
|
|
@@ -357,11 +355,11 @@ var A = e => {
|
|
|
357
355
|
});
|
|
358
356
|
}
|
|
359
357
|
} else {
|
|
360
|
-
for (const s of
|
|
358
|
+
for (const s of i) {
|
|
361
359
|
try {
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
r =
|
|
360
|
+
const o = await s.get(e);
|
|
361
|
+
if (o !== void 0) {
|
|
362
|
+
r = o;
|
|
365
363
|
t.emit("get", {
|
|
366
364
|
key: e,
|
|
367
365
|
value: r
|
|
@@ -390,7 +388,7 @@ var A = e => {
|
|
|
390
388
|
let r;
|
|
391
389
|
if (a) {
|
|
392
390
|
try {
|
|
393
|
-
r = await Promise.race(
|
|
391
|
+
r = await Promise.race(i.map((async t => t.get(e, {
|
|
394
392
|
raw: true
|
|
395
393
|
}))));
|
|
396
394
|
if (r === void 0) {
|
|
@@ -403,13 +401,13 @@ var A = e => {
|
|
|
403
401
|
});
|
|
404
402
|
}
|
|
405
403
|
} else {
|
|
406
|
-
for (const s of
|
|
404
|
+
for (const s of i) {
|
|
407
405
|
try {
|
|
408
|
-
const
|
|
406
|
+
const o = await s.get(e, {
|
|
409
407
|
raw: true
|
|
410
408
|
});
|
|
411
|
-
if (
|
|
412
|
-
r =
|
|
409
|
+
if (o !== void 0) {
|
|
410
|
+
r = o;
|
|
413
411
|
t.emit("ttl", {
|
|
414
412
|
key: e,
|
|
415
413
|
value: r
|
|
@@ -429,26 +427,26 @@ var A = e => {
|
|
|
429
427
|
}
|
|
430
428
|
return void 0;
|
|
431
429
|
};
|
|
432
|
-
const p = async (r, s,
|
|
430
|
+
const p = async (r, s, o, i) => {
|
|
433
431
|
try {
|
|
434
432
|
if (a) {
|
|
435
|
-
Promise.all(r.map((async t => t.set(s,
|
|
433
|
+
Promise.all(r.map((async t => t.set(s, o, i ?? e?.ttl))));
|
|
436
434
|
t.emit("set", {
|
|
437
435
|
key: s,
|
|
438
|
-
value:
|
|
436
|
+
value: o
|
|
439
437
|
});
|
|
440
|
-
return
|
|
438
|
+
return o;
|
|
441
439
|
}
|
|
442
|
-
await Promise.all(r.map((async t => t.set(s,
|
|
440
|
+
await Promise.all(r.map((async t => t.set(s, o, i ?? e?.ttl))));
|
|
443
441
|
t.emit("set", {
|
|
444
442
|
key: s,
|
|
445
|
-
value:
|
|
443
|
+
value: o
|
|
446
444
|
});
|
|
447
|
-
return
|
|
445
|
+
return o;
|
|
448
446
|
} catch (e) {
|
|
449
447
|
t.emit("set", {
|
|
450
448
|
key: s,
|
|
451
|
-
value:
|
|
449
|
+
value: o,
|
|
452
450
|
error: e
|
|
453
451
|
});
|
|
454
452
|
return Promise.reject(e);
|
|
@@ -485,16 +483,16 @@ var A = e => {
|
|
|
485
483
|
return Promise.reject(e);
|
|
486
484
|
}
|
|
487
485
|
};
|
|
488
|
-
const
|
|
486
|
+
const d = async e => {
|
|
489
487
|
try {
|
|
490
488
|
if (a) {
|
|
491
|
-
Promise.all(
|
|
489
|
+
Promise.all(i.map((async t => t.delete(e))));
|
|
492
490
|
t.emit("del", {
|
|
493
491
|
key: e
|
|
494
492
|
});
|
|
495
493
|
return true;
|
|
496
494
|
}
|
|
497
|
-
await Promise.all(
|
|
495
|
+
await Promise.all(i.map((async t => t.delete(e))));
|
|
498
496
|
t.emit("del", {
|
|
499
497
|
key: e
|
|
500
498
|
});
|
|
@@ -507,11 +505,11 @@ var A = e => {
|
|
|
507
505
|
return Promise.reject(r);
|
|
508
506
|
}
|
|
509
507
|
};
|
|
510
|
-
const
|
|
508
|
+
const u = async e => {
|
|
511
509
|
try {
|
|
512
510
|
const r = [];
|
|
513
511
|
for (const t of e) {
|
|
514
|
-
r.push(...
|
|
512
|
+
r.push(...i.map((async e => e.delete(t))));
|
|
515
513
|
}
|
|
516
514
|
if (a) {
|
|
517
515
|
Promise.all(r);
|
|
@@ -533,14 +531,14 @@ var A = e => {
|
|
|
533
531
|
return Promise.reject(r);
|
|
534
532
|
}
|
|
535
533
|
};
|
|
536
|
-
const
|
|
534
|
+
const y = async () => {
|
|
537
535
|
try {
|
|
538
536
|
if (a) {
|
|
539
|
-
Promise.all(
|
|
537
|
+
Promise.all(i.map((async e => e.clear())));
|
|
540
538
|
t.emit("clear");
|
|
541
539
|
return true;
|
|
542
540
|
}
|
|
543
|
-
await Promise.all(
|
|
541
|
+
await Promise.all(i.map((async e => e.clear())));
|
|
544
542
|
t.emit("clear");
|
|
545
543
|
return true;
|
|
546
544
|
} catch (e) {
|
|
@@ -548,19 +546,19 @@ var A = e => {
|
|
|
548
546
|
return Promise.reject(e);
|
|
549
547
|
}
|
|
550
548
|
};
|
|
551
|
-
const
|
|
549
|
+
const f = async (r, s, o, a) => L(`${n}::${r}`, (async () => {
|
|
552
550
|
let c;
|
|
553
551
|
let m;
|
|
554
552
|
let l = 0;
|
|
555
553
|
let h;
|
|
556
|
-
const {ttl:
|
|
557
|
-
ttl:
|
|
554
|
+
const {ttl: d, refreshThreshold: u, raw: y} = T(o) ? o : {
|
|
555
|
+
ttl: o,
|
|
558
556
|
refreshThreshold: a
|
|
559
557
|
};
|
|
560
|
-
const
|
|
561
|
-
for (;l <
|
|
558
|
+
const f = t => _(d, t) ?? e?.ttl;
|
|
559
|
+
for (;l < i.length; l++) {
|
|
562
560
|
try {
|
|
563
|
-
const e = await
|
|
561
|
+
const e = await i[l].get(r, {
|
|
564
562
|
raw: true
|
|
565
563
|
});
|
|
566
564
|
if (e !== void 0) {
|
|
@@ -575,18 +573,18 @@ var A = e => {
|
|
|
575
573
|
}
|
|
576
574
|
if (c === void 0) {
|
|
577
575
|
const e = await s();
|
|
578
|
-
const t =
|
|
579
|
-
await p(
|
|
580
|
-
return
|
|
576
|
+
const t = f(e);
|
|
577
|
+
await p(i, r, e, t);
|
|
578
|
+
return y ? {
|
|
581
579
|
value: e,
|
|
582
580
|
expires: Date.now() + t
|
|
583
581
|
} : e;
|
|
584
582
|
}
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
587
|
-
|
|
583
|
+
const j = D(h, _(u, c) ?? e?.refreshThreshold);
|
|
584
|
+
if (j) {
|
|
585
|
+
L(`+++${n}__${r}`, s).then((async s => {
|
|
588
586
|
try {
|
|
589
|
-
await p(e?.refreshAllStores ?
|
|
587
|
+
await p(e?.refreshAllStores ? i : i.slice(0, l + 1), r, s, f(s));
|
|
590
588
|
t.emit("refresh", {
|
|
591
589
|
key: r,
|
|
592
590
|
value: s
|
|
@@ -606,16 +604,16 @@ var A = e => {
|
|
|
606
604
|
});
|
|
607
605
|
}));
|
|
608
606
|
}
|
|
609
|
-
if (!
|
|
610
|
-
await p(
|
|
607
|
+
if (!j && l > 0) {
|
|
608
|
+
await p(i.slice(0, l), r, c, f(c));
|
|
611
609
|
}
|
|
612
|
-
return
|
|
610
|
+
return y ? m : c;
|
|
613
611
|
}));
|
|
614
|
-
const
|
|
612
|
+
const j = (e, r) => t.addListener(e, r);
|
|
615
613
|
const b = (e, r) => t.removeListener(e, r);
|
|
616
614
|
const v = async () => {
|
|
617
615
|
try {
|
|
618
|
-
await Promise.all(
|
|
616
|
+
await Promise.all(i.map((async e => e.disconnect())));
|
|
619
617
|
} catch (e) {
|
|
620
618
|
return Promise.reject(e);
|
|
621
619
|
}
|
|
@@ -625,47 +623,52 @@ var A = e => {
|
|
|
625
623
|
get: c,
|
|
626
624
|
mget: m,
|
|
627
625
|
ttl: l,
|
|
628
|
-
set: async (e, t, r) => p(
|
|
629
|
-
mset: async e => h(
|
|
630
|
-
del:
|
|
631
|
-
mdel:
|
|
632
|
-
clear:
|
|
633
|
-
wrap:
|
|
634
|
-
on:
|
|
626
|
+
set: async (e, t, r) => p(i, e, t, r),
|
|
627
|
+
mset: async e => h(i, e),
|
|
628
|
+
del: d,
|
|
629
|
+
mdel: u,
|
|
630
|
+
clear: y,
|
|
631
|
+
wrap: f,
|
|
632
|
+
on: j,
|
|
635
633
|
off: b,
|
|
636
634
|
disconnect: v,
|
|
637
635
|
cacheId: g,
|
|
638
|
-
stores:
|
|
636
|
+
stores: i
|
|
639
637
|
};
|
|
640
638
|
};
|
|
641
639
|
|
|
642
|
-
const
|
|
640
|
+
const N = e => ({
|
|
643
641
|
class: Cacher,
|
|
644
|
-
|
|
642
|
+
stores: e?.stores,
|
|
643
|
+
ttl: e?.ttl,
|
|
644
|
+
refreshThreshold: e?.refreshThreshold,
|
|
645
|
+
refreshAllStores: e?.refreshAllStores,
|
|
646
|
+
nonBlocking: e?.nonBlocking,
|
|
647
|
+
cacheId: e?.cacheId
|
|
645
648
|
});
|
|
646
649
|
|
|
647
650
|
class Cacher extends o {
|
|
648
651
|
async init() {
|
|
649
|
-
const e = this.
|
|
652
|
+
const e = this.stores ? Array.isArray(this.stores) ? this.stores : [ this.stores ] : [];
|
|
650
653
|
const t = await Promise.all(e.map((e => {
|
|
651
654
|
switch (e.type) {
|
|
652
655
|
case "file":
|
|
653
|
-
return
|
|
656
|
+
return n(e);
|
|
654
657
|
|
|
655
658
|
case "redis":
|
|
656
|
-
return
|
|
659
|
+
return c(e);
|
|
657
660
|
|
|
658
661
|
case "memcache":
|
|
659
|
-
return
|
|
662
|
+
return m(e);
|
|
660
663
|
|
|
661
664
|
case "mongo":
|
|
662
|
-
return
|
|
665
|
+
return l(e);
|
|
663
666
|
|
|
664
667
|
case "sqlite":
|
|
665
|
-
return
|
|
668
|
+
return p(e);
|
|
666
669
|
|
|
667
670
|
case "postgres":
|
|
668
|
-
return
|
|
671
|
+
return h(e);
|
|
669
672
|
|
|
670
673
|
case "mysql":
|
|
671
674
|
return d(e);
|
|
@@ -675,9 +678,13 @@ class Cacher extends o {
|
|
|
675
678
|
}
|
|
676
679
|
})));
|
|
677
680
|
const r = t.filter((e => !!e));
|
|
678
|
-
this.cache =
|
|
679
|
-
|
|
680
|
-
|
|
681
|
+
this.cache = B({
|
|
682
|
+
stores: r.length ? r : undefined,
|
|
683
|
+
ttl: this.ttl,
|
|
684
|
+
refreshThreshold: this.refreshThreshold,
|
|
685
|
+
refreshAllStores: this.refreshAllStores,
|
|
686
|
+
nonBlocking: this.nonBlocking,
|
|
687
|
+
cacheId: this.cacheId || this.$uuid
|
|
681
688
|
});
|
|
682
689
|
this.cache.on("set", (e => this.emit("set", e)));
|
|
683
690
|
this.cache.on("del", (e => this.emit("del", e)));
|
|
@@ -694,12 +701,12 @@ class Cacher extends o {
|
|
|
694
701
|
return await this.cache.mset(e);
|
|
695
702
|
}
|
|
696
703
|
async get(e) {
|
|
697
|
-
return
|
|
704
|
+
return a(await this.cache.get(e));
|
|
698
705
|
}
|
|
699
706
|
async multipleGet(e) {
|
|
700
707
|
return await this.cache.mget(e);
|
|
701
708
|
}
|
|
702
|
-
async
|
|
709
|
+
async getTTL(e) {
|
|
703
710
|
const t = await this.cache.ttl(e);
|
|
704
711
|
if (t === undefined) return -1;
|
|
705
712
|
return t;
|
|
@@ -718,6 +725,16 @@ class Cacher extends o {
|
|
|
718
725
|
}
|
|
719
726
|
}
|
|
720
727
|
|
|
721
|
-
e([
|
|
728
|
+
e([ i(u.Alternatives(u.Array(u.Alternatives(y.Schema(), f.Schema(), j.Schema(), b.Schema(), v.Schema(), g.Schema(), k.Schema())), y.Schema(), f.Schema(), j.Schema(), b.Schema(), v.Schema(), g.Schema(), k.Schema()).optional()), t("design:type", Object) ], Cacher.prototype, "stores", void 0);
|
|
729
|
+
|
|
730
|
+
e([ i(u.Number().positive().integer().optional()), t("design:type", Number) ], Cacher.prototype, "ttl", void 0);
|
|
731
|
+
|
|
732
|
+
e([ i(u.Number().positive().integer().optional()), t("design:type", Number) ], Cacher.prototype, "refreshThreshold", void 0);
|
|
733
|
+
|
|
734
|
+
e([ i(u.Boolean().optional()), t("design:type", Boolean) ], Cacher.prototype, "refreshAllStores", void 0);
|
|
735
|
+
|
|
736
|
+
e([ i(u.Boolean().optional()), t("design:type", Boolean) ], Cacher.prototype, "nonBlocking", void 0);
|
|
737
|
+
|
|
738
|
+
e([ i(u.String().optional()), t("design:type", String) ], Cacher.prototype, "cacheId", void 0);
|
|
722
739
|
|
|
723
|
-
export {
|
|
740
|
+
export { N as BuildCacherOptions, Cacher };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|