@less-is-more/less-js 1.2.24 → 1.2.25

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@less-is-more/less-js",
3
- "version": "1.2.24",
3
+ "version": "1.2.25",
4
4
  "description": "Fast develop kit for nodejs",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/cache.js CHANGED
@@ -50,12 +50,16 @@ module.exports = class Cache {
50
50
  if (!Param.isBlank(result)) {
51
51
  // 处理JSON
52
52
  if (result instanceof Object) {
53
- await Redis.exec(
54
- "setex",
55
- fullKey,
56
- timeSecond + "",
57
- JSON.stringify(result)
58
- );
53
+ if (result.success === false) {
54
+ console.log("Do not cache fail result");
55
+ } else {
56
+ await Redis.exec(
57
+ "setex",
58
+ fullKey,
59
+ timeSecond + "",
60
+ JSON.stringify(result)
61
+ );
62
+ }
59
63
  } else {
60
64
  await Redis.exec(
61
65
  "setex",
@@ -1,6 +1,7 @@
1
1
  const assert = require("assert");
2
2
  const Cache = require("../src/cache.js");
3
3
  const Redis = require("../src/redis.js");
4
+ const Ret = require("../src/ret.js");
4
5
 
5
6
  describe("cache.js", () => {
6
7
  before(() => {
@@ -92,5 +93,15 @@ describe("cache.js", () => {
92
93
  console.log("result", JSON.stringify(result));
93
94
  assert(result.length === 1);
94
95
  });
96
+ it("no cache fail", async () => {
97
+ async function test(a, b) {
98
+ return await Cache.auto("test5", 20, arguments, () => {
99
+ return new Ret(false);
100
+ });
101
+ }
102
+ const result = await test(1, 2);
103
+ console.log("result", JSON.stringify(result));
104
+ assert(result.success === false);
105
+ });
95
106
  });
96
107
  });