Skip to content

Commit

Permalink
fix(app): Redis client error fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ful1e5 committed Nov 14, 2023
1 parent 53a4a5e commit 8146b93
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/services/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ export class ImageRedis {
constructor() {}

private __createClient() {
return new Redis({
const client = new Redis({
host: process.env.REDIS_HOST,
password: process.env.REDIS_PASSWORD,
port: process.env.REDIS_PORT
}).on('error', (err) => {
if (err.code == 'ECONNREFUSED') {
});
client.on('error', (err) => {
if (err) {
if (process.env.NODE_ENV === 'development') {
console.error(err.stack);
} else {
console.error(err.message);
}
client.disconnect();
return;
}

if (process.env.NODE_ENV === 'development') {
console.error(err.stack);
} else {
console.error(err.message);
}
return;
});
return client;
}

public async del(key: RedisKey) {
Expand Down

0 comments on commit 8146b93

Please sign in to comment.