@zenweb/cache 4.1.1 → 4.1.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.1.2] - 2023-8-21
4
+ fix: 首次缓存新数据时会返回压缩数据的问题
5
+
3
6
  ## [4.1.1] - 2023-8-18
4
7
  增加 normalKey number 参数
5
8
 
package/dist/cache.js CHANGED
@@ -121,7 +121,7 @@ class Cache {
121
121
  if ((_opt === null || _opt === void 0 ? void 0 : _opt.parse) !== false) {
122
122
  return obj;
123
123
  }
124
- return new CacheResult(!!result.compressed, result.compressed || Buffer.from(result.data));
124
+ return new CacheResult(!opt.decompress && result.compressed !== undefined, !opt.decompress && result.compressed || Buffer.from(result.data));
125
125
  };
126
126
  // 预刷新处理
127
127
  const preRefresh = async () => {
@@ -19,7 +19,7 @@ function cached(key, opt) {
19
19
  await next();
20
20
  return ctx.body;
21
21
  }, _opt);
22
- if (!decompress && result.compressed) {
22
+ if (result.compressed) {
23
23
  ctx.set('Content-Encoding', 'gzip');
24
24
  }
25
25
  if (!ctx.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenweb/cache",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
4
4
  "description": "Zenweb Cache module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",