mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-18 00:10:32 +00:00
34 lines
640 B
TypeScript
34 lines
640 B
TypeScript
import { createClient } from 'redis';
|
|
|
|
export abstract class BaseRedisRepository {
|
|
protected redisClient;
|
|
|
|
constructor(
|
|
redisClient = createClient({
|
|
url: process.env.REDIS_URL,
|
|
socket: {
|
|
tls: process.env.NODE_ENV === 'production',
|
|
rejectUnauthorized: false,
|
|
}
|
|
}),
|
|
) {
|
|
this.redisClient = redisClient;
|
|
}
|
|
|
|
get isReady() {
|
|
return this.redisClient.isReady;
|
|
}
|
|
|
|
public async connect() {
|
|
await this.redisClient.connect();
|
|
}
|
|
|
|
public async disconnect() {
|
|
await this.redisClient.disconnect();
|
|
}
|
|
|
|
public async clearAllData() {
|
|
await this.redisClient.flushAll();
|
|
}
|
|
}
|