@less-is-more/less-js 1.5.0-8 → 1.5.0-9
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/package.json +1 -1
- package/src/cache.js +9 -9
package/package.json
CHANGED
package/src/cache.js
CHANGED
|
@@ -74,29 +74,29 @@ module.exports = class Cache {
|
|
|
74
74
|
if (savedData == null) {
|
|
75
75
|
let result = await fn();
|
|
76
76
|
if (!Param.isBlank(result)) {
|
|
77
|
-
let
|
|
77
|
+
let saveContent = "";
|
|
78
78
|
// 处理JSON
|
|
79
79
|
if (result instanceof Object) {
|
|
80
80
|
if (result.success === false) {
|
|
81
81
|
console.log("Do not cache fail result");
|
|
82
82
|
} else {
|
|
83
|
-
|
|
83
|
+
saveContent = JSON.stringify(result);
|
|
84
84
|
}
|
|
85
85
|
} else {
|
|
86
|
-
|
|
86
|
+
saveContent = result.toString();
|
|
87
87
|
}
|
|
88
|
-
if (
|
|
89
|
-
if (Cache._needZip(
|
|
90
|
-
|
|
88
|
+
if (saveContent != "") {
|
|
89
|
+
if (Cache._needZip(saveContent, zip)) {
|
|
90
|
+
saveContent = Cache._zip(saveContent);
|
|
91
91
|
}
|
|
92
92
|
if (useNas) {
|
|
93
|
-
Nas.set(fullKey,
|
|
93
|
+
Nas.set(fullKey, saveContent, timeSecond);
|
|
94
94
|
} else {
|
|
95
|
-
await Redis.exec("setex", fullKey, timeSecond + "",
|
|
95
|
+
await Redis.exec("setex", fullKey, timeSecond + "", saveContent);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// 本地缓存1分钟
|
|
99
|
-
Cache._setLocal(fullKey,
|
|
99
|
+
Cache._setLocal(fullKey, saveContent, 60000);
|
|
100
100
|
}
|
|
101
101
|
return result;
|
|
102
102
|
}
|