Skip to content

Commit

Permalink
Fix: allow reconnect cache on each command
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed Sep 28, 2022
1 parent e7294a4 commit 3484143
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,23 @@ export default class Cache {
database : redisConf.database
});
this.ttl = ttl / MS_TO_SEC;
this.connected = false;
CACHES.push(this);
}

async connect() {
if (this.connected) return;

try {
await this.client.connect();
} catch (error) {
if (error.message !== 'Socket already opened') throw error;
}

this.connected = true;
}

async close() {
if (!this.connected) return;
try {
await this.client.quit();
} catch (error) {
if (![ 'The client is closed', 'This socket has been ended by the other party' ].includes(error.message)) throw error;
}

this.connected = false;
}

async saveAll(keys) {
Expand Down

0 comments on commit 3484143

Please sign in to comment.