|
@@ -31,13 +31,12 @@ const client = redis.createClient({
|
|
}
|
|
}
|
|
if (options.attempt > 10) {
|
|
if (options.attempt > 10) {
|
|
// End reconnecting with built in error
|
|
// End reconnecting with built in error
|
|
- return undefined;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
// reconnect after
|
|
// reconnect after
|
|
- return Math.min(options.attempt * 100, 3000);
|
|
|
|
|
|
+ return Math.min(options.attempt * 1000, 3000);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
client.on('error', err => {
|
|
client.on('error', err => {
|
|
consola.error(err);
|
|
consola.error(err);
|
|
});
|
|
});
|
|
@@ -57,9 +56,9 @@ client.on('end', () => {
|
|
|
|
|
|
// redis查询和设置await/async化
|
|
// redis查询和设置await/async化
|
|
const promisify = util.promisify;
|
|
const promisify = util.promisify;
|
|
-const getClient = (key) => promisify(client.get).bind(client, key);
|
|
|
|
-const setClient = (key, value) => promisify(client.set).bind(client, key, value);
|
|
|
|
-const setexClient = (key, ttl, value) => promisify(client.setex).bind(client, key, ttl, value);
|
|
|
|
|
|
+const getClient = (key) => promisify(client.get).bind(client)(key);
|
|
|
|
+const setClient = (key, value) => promisify(client.set).bind(client)(key, value);
|
|
|
|
+const setexClient = (key, ttl, value) => promisify(client.setex).bind(client)(key, ttl, value);
|
|
|
|
|
|
// 内存存储promise化,为了和redis使用方法保持一致
|
|
// 内存存储promise化,为了和redis使用方法保持一致
|
|
const getCache = (key: string): Promise<string|undefined> => {
|
|
const getCache = (key: string): Promise<string|undefined> => {
|