vona-module-a-summer 5.0.21 → 5.0.23
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/common/cacheBase.d.ts +0 -66
- package/dist/config/config.d.ts +0 -132
- package/dist/index.js +26 -25
- package/dist/types/summerCache.d.ts +2 -1
- package/package.json +1 -1
|
@@ -18,74 +18,8 @@ export declare class CacheBase<KEY = any, DATA = any> extends BeanBase {
|
|
|
18
18
|
presetDefault: import("../types/summerCache.ts").TSummerCachePreset;
|
|
19
19
|
preset: {
|
|
20
20
|
mem: IDecoratorSummerCacheOptions;
|
|
21
|
-
memWithIgnoreNull: {
|
|
22
|
-
ignoreNull: boolean;
|
|
23
|
-
preset?: import("../types/summerCache.ts").TSummerCachePreset;
|
|
24
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
25
|
-
mem?: {
|
|
26
|
-
max?: number;
|
|
27
|
-
ttl?: number;
|
|
28
|
-
updateAgeOnGet?: boolean;
|
|
29
|
-
updateAgeOnHas?: boolean;
|
|
30
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
31
|
-
disableInstance?: boolean;
|
|
32
|
-
};
|
|
33
|
-
redis?: {
|
|
34
|
-
ttl?: number;
|
|
35
|
-
updateAgeOnGet?: boolean;
|
|
36
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
37
|
-
disableInstance?: boolean;
|
|
38
|
-
};
|
|
39
|
-
emptyArrayAsNull?: boolean;
|
|
40
|
-
enable?: boolean;
|
|
41
|
-
meta?: Omit<import("vona-module-a-onion").IOnionOptionsMeta, never> | undefined;
|
|
42
|
-
};
|
|
43
21
|
redis: IDecoratorSummerCacheOptions;
|
|
44
|
-
redisWithIgnoreNull: {
|
|
45
|
-
ignoreNull: boolean;
|
|
46
|
-
preset?: import("../types/summerCache.ts").TSummerCachePreset;
|
|
47
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
48
|
-
mem?: {
|
|
49
|
-
max?: number;
|
|
50
|
-
ttl?: number;
|
|
51
|
-
updateAgeOnGet?: boolean;
|
|
52
|
-
updateAgeOnHas?: boolean;
|
|
53
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
54
|
-
disableInstance?: boolean;
|
|
55
|
-
};
|
|
56
|
-
redis?: {
|
|
57
|
-
ttl?: number;
|
|
58
|
-
updateAgeOnGet?: boolean;
|
|
59
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
60
|
-
disableInstance?: boolean;
|
|
61
|
-
};
|
|
62
|
-
emptyArrayAsNull?: boolean;
|
|
63
|
-
enable?: boolean;
|
|
64
|
-
meta?: Omit<import("vona-module-a-onion").IOnionOptionsMeta, never> | undefined;
|
|
65
|
-
};
|
|
66
22
|
all: IDecoratorSummerCacheOptions;
|
|
67
|
-
allWithIgnoreNull: {
|
|
68
|
-
ignoreNull: boolean;
|
|
69
|
-
preset?: import("../types/summerCache.ts").TSummerCachePreset;
|
|
70
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
71
|
-
mem?: {
|
|
72
|
-
max?: number;
|
|
73
|
-
ttl?: number;
|
|
74
|
-
updateAgeOnGet?: boolean;
|
|
75
|
-
updateAgeOnHas?: boolean;
|
|
76
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
77
|
-
disableInstance?: boolean;
|
|
78
|
-
};
|
|
79
|
-
redis?: {
|
|
80
|
-
ttl?: number;
|
|
81
|
-
updateAgeOnGet?: boolean;
|
|
82
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
83
|
-
disableInstance?: boolean;
|
|
84
|
-
};
|
|
85
|
-
emptyArrayAsNull?: boolean;
|
|
86
|
-
enable?: boolean;
|
|
87
|
-
meta?: Omit<import("vona-module-a-onion").IOnionOptionsMeta, never> | undefined;
|
|
88
|
-
};
|
|
89
23
|
};
|
|
90
24
|
redis: {
|
|
91
25
|
client: string;
|
package/dist/config/config.d.ts
CHANGED
|
@@ -2,74 +2,8 @@ import type { VonaApplication } from 'vona';
|
|
|
2
2
|
import type { IOnionOptionsMeta } from 'vona-module-a-onion';
|
|
3
3
|
import type { IDecoratorSummerCacheOptions, TSummerCachePreset } from '../types/summerCache.ts';
|
|
4
4
|
export declare const configMem: IDecoratorSummerCacheOptions;
|
|
5
|
-
export declare const configMemWithIgnoreNull: {
|
|
6
|
-
ignoreNull: boolean;
|
|
7
|
-
preset?: TSummerCachePreset;
|
|
8
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
9
|
-
mem?: {
|
|
10
|
-
max?: number;
|
|
11
|
-
ttl?: number;
|
|
12
|
-
updateAgeOnGet?: boolean;
|
|
13
|
-
updateAgeOnHas?: boolean;
|
|
14
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
15
|
-
disableInstance?: boolean;
|
|
16
|
-
};
|
|
17
|
-
redis?: {
|
|
18
|
-
ttl?: number;
|
|
19
|
-
updateAgeOnGet?: boolean;
|
|
20
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
21
|
-
disableInstance?: boolean;
|
|
22
|
-
};
|
|
23
|
-
emptyArrayAsNull?: boolean;
|
|
24
|
-
enable?: boolean;
|
|
25
|
-
meta?: Omit<IOnionOptionsMeta, never> | undefined;
|
|
26
|
-
};
|
|
27
5
|
export declare const configRedis: IDecoratorSummerCacheOptions;
|
|
28
|
-
export declare const configRedisWithIgnoreNull: {
|
|
29
|
-
ignoreNull: boolean;
|
|
30
|
-
preset?: TSummerCachePreset;
|
|
31
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
32
|
-
mem?: {
|
|
33
|
-
max?: number;
|
|
34
|
-
ttl?: number;
|
|
35
|
-
updateAgeOnGet?: boolean;
|
|
36
|
-
updateAgeOnHas?: boolean;
|
|
37
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
38
|
-
disableInstance?: boolean;
|
|
39
|
-
};
|
|
40
|
-
redis?: {
|
|
41
|
-
ttl?: number;
|
|
42
|
-
updateAgeOnGet?: boolean;
|
|
43
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
44
|
-
disableInstance?: boolean;
|
|
45
|
-
};
|
|
46
|
-
emptyArrayAsNull?: boolean;
|
|
47
|
-
enable?: boolean;
|
|
48
|
-
meta?: Omit<IOnionOptionsMeta, never> | undefined;
|
|
49
|
-
};
|
|
50
6
|
export declare const configAll: IDecoratorSummerCacheOptions;
|
|
51
|
-
export declare const configAllWithIgnoreNull: {
|
|
52
|
-
ignoreNull: boolean;
|
|
53
|
-
preset?: TSummerCachePreset;
|
|
54
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
55
|
-
mem?: {
|
|
56
|
-
max?: number;
|
|
57
|
-
ttl?: number;
|
|
58
|
-
updateAgeOnGet?: boolean;
|
|
59
|
-
updateAgeOnHas?: boolean;
|
|
60
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
61
|
-
disableInstance?: boolean;
|
|
62
|
-
};
|
|
63
|
-
redis?: {
|
|
64
|
-
ttl?: number;
|
|
65
|
-
updateAgeOnGet?: boolean;
|
|
66
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
67
|
-
disableInstance?: boolean;
|
|
68
|
-
};
|
|
69
|
-
emptyArrayAsNull?: boolean;
|
|
70
|
-
enable?: boolean;
|
|
71
|
-
meta?: Omit<IOnionOptionsMeta, never> | undefined;
|
|
72
|
-
};
|
|
73
7
|
export declare function config(_app: VonaApplication): {
|
|
74
8
|
summer: {
|
|
75
9
|
enable: boolean;
|
|
@@ -77,74 +11,8 @@ export declare function config(_app: VonaApplication): {
|
|
|
77
11
|
presetDefault: TSummerCachePreset;
|
|
78
12
|
preset: {
|
|
79
13
|
mem: IDecoratorSummerCacheOptions;
|
|
80
|
-
memWithIgnoreNull: {
|
|
81
|
-
ignoreNull: boolean;
|
|
82
|
-
preset?: TSummerCachePreset;
|
|
83
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
84
|
-
mem?: {
|
|
85
|
-
max?: number;
|
|
86
|
-
ttl?: number;
|
|
87
|
-
updateAgeOnGet?: boolean;
|
|
88
|
-
updateAgeOnHas?: boolean;
|
|
89
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
90
|
-
disableInstance?: boolean;
|
|
91
|
-
};
|
|
92
|
-
redis?: {
|
|
93
|
-
ttl?: number;
|
|
94
|
-
updateAgeOnGet?: boolean;
|
|
95
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
96
|
-
disableInstance?: boolean;
|
|
97
|
-
};
|
|
98
|
-
emptyArrayAsNull?: boolean;
|
|
99
|
-
enable?: boolean;
|
|
100
|
-
meta?: Omit<IOnionOptionsMeta, never> | undefined;
|
|
101
|
-
};
|
|
102
14
|
redis: IDecoratorSummerCacheOptions;
|
|
103
|
-
redisWithIgnoreNull: {
|
|
104
|
-
ignoreNull: boolean;
|
|
105
|
-
preset?: TSummerCachePreset;
|
|
106
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
107
|
-
mem?: {
|
|
108
|
-
max?: number;
|
|
109
|
-
ttl?: number;
|
|
110
|
-
updateAgeOnGet?: boolean;
|
|
111
|
-
updateAgeOnHas?: boolean;
|
|
112
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
113
|
-
disableInstance?: boolean;
|
|
114
|
-
};
|
|
115
|
-
redis?: {
|
|
116
|
-
ttl?: number;
|
|
117
|
-
updateAgeOnGet?: boolean;
|
|
118
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
119
|
-
disableInstance?: boolean;
|
|
120
|
-
};
|
|
121
|
-
emptyArrayAsNull?: boolean;
|
|
122
|
-
enable?: boolean;
|
|
123
|
-
meta?: Omit<IOnionOptionsMeta, never> | undefined;
|
|
124
|
-
};
|
|
125
15
|
all: IDecoratorSummerCacheOptions;
|
|
126
|
-
allWithIgnoreNull: {
|
|
127
|
-
ignoreNull: boolean;
|
|
128
|
-
preset?: TSummerCachePreset;
|
|
129
|
-
mode?: import("../types/summerCache.ts").TSummerCacheMode;
|
|
130
|
-
mem?: {
|
|
131
|
-
max?: number;
|
|
132
|
-
ttl?: number;
|
|
133
|
-
updateAgeOnGet?: boolean;
|
|
134
|
-
updateAgeOnHas?: boolean;
|
|
135
|
-
broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
|
|
136
|
-
disableInstance?: boolean;
|
|
137
|
-
};
|
|
138
|
-
redis?: {
|
|
139
|
-
ttl?: number;
|
|
140
|
-
updateAgeOnGet?: boolean;
|
|
141
|
-
client?: keyof import("vona-module-a-redis").IRedisClientRecord;
|
|
142
|
-
disableInstance?: boolean;
|
|
143
|
-
};
|
|
144
|
-
emptyArrayAsNull?: boolean;
|
|
145
|
-
enable?: boolean;
|
|
146
|
-
meta?: Omit<IOnionOptionsMeta, never> | undefined;
|
|
147
|
-
};
|
|
148
16
|
};
|
|
149
17
|
redis: {
|
|
150
18
|
client: string;
|
package/dist/index.js
CHANGED
|
@@ -226,11 +226,12 @@ let ServiceLocalMem = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
226
226
|
module: "a-summer"
|
|
227
227
|
}), _dec$2(_class$2 = _dec2$2(_class$2 = class ServiceLocalMem extends CacheBase {
|
|
228
228
|
async get(key, options) {
|
|
229
|
-
|
|
229
|
+
const force = options?.force;
|
|
230
|
+
let value = force ? undefined : this.cacheMem.get(key, {
|
|
230
231
|
ttl: options?.ttl,
|
|
231
232
|
updateAgeOnGet: options?.updateAgeOnGet
|
|
232
233
|
});
|
|
233
|
-
if (this.__checkValueEmpty(value, options)) {
|
|
234
|
+
if (force || this.__checkValueEmpty(value, options)) {
|
|
234
235
|
const layered = this.__getLayered(options);
|
|
235
236
|
value = await layered.get(key, options);
|
|
236
237
|
this.cacheMem.set(value, key, {
|
|
@@ -242,15 +243,16 @@ let ServiceLocalMem = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
242
243
|
return value;
|
|
243
244
|
}
|
|
244
245
|
async mget(keys, options) {
|
|
246
|
+
const force = options?.force;
|
|
245
247
|
// mget
|
|
246
|
-
const values = this.cacheMem.mget(keys, {
|
|
248
|
+
const values = force ? keys.map(() => undefined) : this.cacheMem.mget(keys, {
|
|
247
249
|
ttl: options?.ttl,
|
|
248
250
|
updateAgeOnGet: options?.updateAgeOnGet
|
|
249
251
|
});
|
|
250
252
|
const keysMissing = [];
|
|
251
253
|
const indexesMissing = [];
|
|
252
254
|
for (let i = 0; i < values.length; i++) {
|
|
253
|
-
if (this.__checkValueEmpty(values[i], options)) {
|
|
255
|
+
if (force || this.__checkValueEmpty(values[i], options)) {
|
|
254
256
|
keysMissing.push(keys[i]);
|
|
255
257
|
indexesMissing.push(i);
|
|
256
258
|
}
|
|
@@ -342,11 +344,12 @@ let ServiceLocalRedis = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
|
342
344
|
module: "a-summer"
|
|
343
345
|
}), _dec$1(_class$1 = _dec2$1(_class$1 = class ServiceLocalRedis extends CacheBase {
|
|
344
346
|
async get(key, options) {
|
|
345
|
-
|
|
347
|
+
const force = options?.force;
|
|
348
|
+
let value = force ? undefined : await this.cacheRedis.get(key, {
|
|
346
349
|
ttl: options?.ttl,
|
|
347
350
|
updateAgeOnGet: options?.updateAgeOnGet
|
|
348
351
|
});
|
|
349
|
-
if (this.__checkValueEmpty(value, options)) {
|
|
352
|
+
if (force || this.__checkValueEmpty(value, options)) {
|
|
350
353
|
const layered = this.__getLayered(options);
|
|
351
354
|
value = await layered.get(key, options);
|
|
352
355
|
await this.cacheRedis.set(value, key, {
|
|
@@ -357,15 +360,16 @@ let ServiceLocalRedis = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
|
357
360
|
return value;
|
|
358
361
|
}
|
|
359
362
|
async mget(keys, options) {
|
|
363
|
+
const force = options?.force;
|
|
360
364
|
// mget
|
|
361
|
-
const values = await this.cacheRedis.mget(keys, {
|
|
365
|
+
const values = force ? keys.map(() => undefined) : await this.cacheRedis.mget(keys, {
|
|
362
366
|
ttl: options?.ttl,
|
|
363
367
|
updateAgeOnGet: options?.updateAgeOnGet
|
|
364
368
|
});
|
|
365
369
|
const keysMissing = [];
|
|
366
370
|
const indexesMissing = [];
|
|
367
371
|
for (let i = 0; i < values.length; i++) {
|
|
368
|
-
if (this.__checkValueEmpty(values[i], options)) {
|
|
372
|
+
if (force || this.__checkValueEmpty(values[i], options)) {
|
|
369
373
|
keysMissing.push(keys[i]);
|
|
370
374
|
indexesMissing.push(i);
|
|
371
375
|
}
|
|
@@ -434,10 +438,9 @@ const configMem = {
|
|
|
434
438
|
broadcastOnSet: 'del'
|
|
435
439
|
}
|
|
436
440
|
};
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
};
|
|
441
|
+
|
|
442
|
+
// export const configMemWithIgnoreNull = { ...configMem, ignoreNull: true };
|
|
443
|
+
|
|
441
444
|
const configRedis = {
|
|
442
445
|
mode: 'redis',
|
|
443
446
|
// only redis
|
|
@@ -445,10 +448,9 @@ const configRedis = {
|
|
|
445
448
|
ttl: 20 * 60 * 1000 // 20 minutes
|
|
446
449
|
}
|
|
447
450
|
};
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
};
|
|
451
|
+
|
|
452
|
+
// export const configRedisWithIgnoreNull = { ...configRedis, ignoreNull: true };
|
|
453
|
+
|
|
452
454
|
const configAll = {
|
|
453
455
|
mode: 'all',
|
|
454
456
|
mem: {
|
|
@@ -459,10 +461,9 @@ const configAll = {
|
|
|
459
461
|
ttl: 20 * 60 * 1000 // 20 minutes
|
|
460
462
|
}
|
|
461
463
|
};
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
};
|
|
464
|
+
|
|
465
|
+
// export const configAllWithIgnoreNull = { ...configAll, ignoreNull: true };
|
|
466
|
+
|
|
466
467
|
function config(_app) {
|
|
467
468
|
return {
|
|
468
469
|
summer: {
|
|
@@ -471,11 +472,11 @@ function config(_app) {
|
|
|
471
472
|
presetDefault: 'all',
|
|
472
473
|
preset: {
|
|
473
474
|
mem: configMem,
|
|
474
|
-
memWithIgnoreNull: configMemWithIgnoreNull,
|
|
475
475
|
redis: configRedis,
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
all: configAll
|
|
477
|
+
// memWithIgnoreNull: configMemWithIgnoreNull,
|
|
478
|
+
// redisWithIgnoreNull: configRedisWithIgnoreNull,
|
|
479
|
+
// allWithIgnoreNull: configAllWithIgnoreNull,
|
|
479
480
|
},
|
|
480
481
|
redis: {
|
|
481
482
|
client: 'summer'
|
|
@@ -495,4 +496,4 @@ function SummerCache(options) {
|
|
|
495
496
|
return createBeanDecorator('summerCache', options);
|
|
496
497
|
}
|
|
497
498
|
|
|
498
|
-
export { BeanSummer, BeanSummerCacheBase, ScopeModuleASummer, ServiceLocalFetch, ServiceLocalMem, ServiceLocalRedis, SummerCache, config, configAll,
|
|
499
|
+
export { BeanSummer, BeanSummerCacheBase, ScopeModuleASummer, ServiceLocalFetch, ServiceLocalMem, ServiceLocalRedis, SummerCache, config, configAll, configMem, configRedis };
|
|
@@ -12,7 +12,7 @@ export interface ISummerCacheGet<KEY, DATA> {
|
|
|
12
12
|
export interface ISummerCacheMGet<KEY, DATA> {
|
|
13
13
|
mgetNative(keys: KEY[], options?: TSummerCacheActionOptions<KEY, DATA>): Promise<Array<DATA | null | undefined>>;
|
|
14
14
|
}
|
|
15
|
-
export type TSummerCachePreset = 'mem' | 'redis' | 'all'
|
|
15
|
+
export type TSummerCachePreset = 'mem' | 'redis' | 'all';
|
|
16
16
|
export type TSummerCacheMode = 'all' | 'mem' | 'redis';
|
|
17
17
|
export interface IDecoratorSummerCacheOptions extends IOnionOptionsEnable {
|
|
18
18
|
preset?: TSummerCachePreset;
|
|
@@ -41,6 +41,7 @@ export interface TSummerCacheActionOptions<KEY, DATA> {
|
|
|
41
41
|
emptyArrayAsNull?: boolean;
|
|
42
42
|
db?: ServiceDb;
|
|
43
43
|
ttl?: number;
|
|
44
|
+
force?: boolean;
|
|
44
45
|
updateAgeOnGet?: boolean;
|
|
45
46
|
broadcastOnSet?: TypeBroadcastOnSet;
|
|
46
47
|
get?: (key?: KEY, options?: TSummerCacheActionOptions<KEY, DATA>) => Promise<DATA | null | undefined>;
|