@zenweb/cache 4.2.2 → 4.3.0
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 +4 -0
- package/dist/cache.js +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cache.js
CHANGED
|
@@ -138,7 +138,7 @@ class Cache {
|
|
|
138
138
|
// 使用锁设置缓存
|
|
139
139
|
let locker;
|
|
140
140
|
let refresh = opt.refresh || false; // 强制刷新
|
|
141
|
-
let retryCount = typeof opt.retryCount === 'number' ? opt.retryCount :
|
|
141
|
+
let retryCount = typeof opt.retryCount === 'number' ? opt.retryCount : 10;
|
|
142
142
|
while (true) {
|
|
143
143
|
if (!refresh) {
|
|
144
144
|
// 尝试从 redis 中获取
|
package/dist/types.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -21,4 +21,4 @@ export declare function runRedisScript(redis: Redis, hash: string, script: strin
|
|
|
21
21
|
* 生成一个参数缓存key
|
|
22
22
|
* - 多个元素用 : 连接
|
|
23
23
|
*/
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function cacheKey(...key: (string | number | object)[]): string;
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.cacheKey = exports.runRedisScript = exports.sleep = exports.debug = void 0;
|
|
4
4
|
const debug_1 = require("debug");
|
|
5
5
|
const crypto = require("crypto");
|
|
6
6
|
exports.debug = (0, debug_1.default)('zenweb:cache');
|
|
@@ -69,11 +69,11 @@ function plainifyOrHash(obj) {
|
|
|
69
69
|
* 生成一个参数缓存key
|
|
70
70
|
* - 多个元素用 : 连接
|
|
71
71
|
*/
|
|
72
|
-
function
|
|
72
|
+
function cacheKey(...key) {
|
|
73
73
|
return key.map(i => {
|
|
74
74
|
if (typeof i === 'string')
|
|
75
75
|
return i;
|
|
76
76
|
return plainifyOrHash(i);
|
|
77
77
|
}).join(':');
|
|
78
78
|
}
|
|
79
|
-
exports.
|
|
79
|
+
exports.cacheKey = cacheKey;
|