@azteam/express 1.2.332 → 1.2.333
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.
|
@@ -29,7 +29,7 @@ function _default(key) {
|
|
|
29
29
|
case 0:
|
|
30
30
|
redis = req.redis;
|
|
31
31
|
if (!redis) {
|
|
32
|
-
_context.next =
|
|
32
|
+
_context.next = 18;
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
35
|
cacheKey = key;
|
|
@@ -55,18 +55,27 @@ function _default(key) {
|
|
|
55
55
|
case 12:
|
|
56
56
|
cacheData = _context.sent;
|
|
57
57
|
if (!cacheData) {
|
|
58
|
-
_context.next =
|
|
58
|
+
_context.next = 17;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
if (cacheData.success) {
|
|
62
|
+
_context.next = 16;
|
|
59
63
|
break;
|
|
60
64
|
}
|
|
65
|
+
return _context.abrupt("return", res.json({
|
|
66
|
+
success: true,
|
|
67
|
+
data: cacheData
|
|
68
|
+
}));
|
|
69
|
+
case 16:
|
|
61
70
|
return _context.abrupt("return", res.json(cacheData));
|
|
62
|
-
case
|
|
71
|
+
case 17:
|
|
63
72
|
res.cache = {
|
|
64
73
|
key: cacheKey,
|
|
65
74
|
ttl: options.ttl
|
|
66
75
|
};
|
|
67
|
-
case
|
|
76
|
+
case 18:
|
|
68
77
|
return _context.abrupt("return", next());
|
|
69
|
-
case
|
|
78
|
+
case 19:
|
|
70
79
|
case "end":
|
|
71
80
|
return _context.stop();
|
|
72
81
|
}
|
package/package.json
CHANGED
|
@@ -25,6 +25,10 @@ export default function (key, options = {}) {
|
|
|
25
25
|
}
|
|
26
26
|
const cacheData = await redis.get(cacheKey);
|
|
27
27
|
if (cacheData) {
|
|
28
|
+
if (!cacheData.success) {
|
|
29
|
+
return res.json({success: true, data: cacheData});
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
return res.json(cacheData);
|
|
29
33
|
}
|
|
30
34
|
res.cache = {
|