mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 00:10:58 -05:00
Replace janky reconnect method with a reliable one from the package.
This commit is contained in:
parent
5f29723247
commit
70acd9b7bf
@ -6,7 +6,7 @@ const RedisClient = createClient({
|
||||
url: (await TSClient()).redis_uri,
|
||||
database: 0,
|
||||
name: 'Daggerbot',
|
||||
socket: { keepAlive: 15000, timeout: 30000 }
|
||||
socket: { keepAlive: 15000, timeout: 30000, reconnectStrategy(retries:number = 5) {return Math.min(retries * 76, 1000)} }
|
||||
});
|
||||
|
||||
export default class CacheServer {
|
||||
@ -14,16 +14,7 @@ export default class CacheServer {
|
||||
protected static eventManager() {
|
||||
RedisClient
|
||||
.on('connect', ()=>Logger.console('log', this.prefix, 'Connection to Redis has been established'))
|
||||
.on('error', (err:ErrorReply)=>{
|
||||
Logger.console('error', this.prefix, `Encountered an error in Redis: ${err.message}`)
|
||||
setTimeout(async()=>{
|
||||
if (!RedisClient.isReady) {
|
||||
Logger.console('log', this.prefix, 'Client is zombified, starting a fresh connection...');
|
||||
RedisClient.quit();
|
||||
await RedisClient.connect();
|
||||
}
|
||||
}, 1500)
|
||||
})
|
||||
.on('error', (err:ErrorReply)=>Logger.console('error', this.prefix, `Encountered an error in Redis: ${err.message}`))
|
||||
}
|
||||
public static async get(key:any, jsonMode:boolean):Promise<any> {
|
||||
let cachedResult:any;
|
||||
|
Loading…
Reference in New Issue
Block a user