@midwayjs/cache-manager 3.16.2 → 3.16.3
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/store.js +21 -7
- package/package.json +2 -2
package/dist/store.js
CHANGED
|
@@ -20,8 +20,14 @@ function createStore(redisCache, options) {
|
|
|
20
20
|
const val = await redisCache.get(key);
|
|
21
21
|
if (val === undefined || val === null)
|
|
22
22
|
return undefined;
|
|
23
|
-
else
|
|
24
|
-
|
|
23
|
+
else {
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(val);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return val;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
25
31
|
},
|
|
26
32
|
async set(key, value, ttl) {
|
|
27
33
|
if (!isCacheable(value))
|
|
@@ -50,11 +56,19 @@ function createStore(redisCache, options) {
|
|
|
50
56
|
return [key, getVal(value)];
|
|
51
57
|
}));
|
|
52
58
|
},
|
|
53
|
-
mget: (...args) => redisCache
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
mget: (...args) => redisCache.mget(args).then(x => x.map(x => {
|
|
60
|
+
if (x === null || x === undefined) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(x);
|
|
66
|
+
}
|
|
67
|
+
catch (_a) {
|
|
68
|
+
return x;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})),
|
|
58
72
|
async mdel(...args) {
|
|
59
73
|
await redisCache.del(args);
|
|
60
74
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/cache-manager",
|
|
3
|
-
"version": "3.16.
|
|
3
|
+
"version": "3.16.3",
|
|
4
4
|
"description": "midway cache manager",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"lodash.clonedeep": "4.5.0",
|
|
38
38
|
"lru-cache": "7.18.3"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "3b547e92cf7150b0e6fbfb3d20e9065039743337"
|
|
41
41
|
}
|