Add BaseRedisRepository as parent class of RedisNotificationRepository.ts and RedisParkingRepository.ts

This commit is contained in:
2025-07-02 20:00:44 -04:00
parent 19336ce6ec
commit 53632fe470
3 changed files with 56 additions and 85 deletions

View File

@@ -0,0 +1,33 @@
import { createClient } from 'redis';
export abstract class BaseRedisRepository {
protected redisClient;
constructor(
redisClient = createClient({
url: process.env.REDIS_URL,
socket: {
tls: (process.env.REDIS_URL?.match(/rediss:/) != null),
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();
}
}