This commit is contained in:
Boki 2025-06-10 15:07:37 -04:00
parent 32d0eaac2d
commit 9825e99540
3 changed files with 68 additions and 59 deletions

View file

@ -46,32 +46,31 @@ export class RedisCache implements CacheProvider {
}
private setupEventHandlers(): void {
// this.redis.on('connect', () => {
// this.logger.info('Redis cache connected');
// });
this.redis.on('connect', () => {
this.logger.info('Redis cache connected');
});
// this.redis.on('ready', () => {
// this.isConnected = true;
// this.logger.info('Redis cache ready');
// });
this.redis.on('ready', () => {
this.isConnected = true;
this.logger.info('Redis cache ready');
});
// this.redis.on('error', (error: any) => {
// this.isConnected = false;
// this.logger.error('Redis cache connection error', { error: error.message });
// });
this.redis.on('error', (error: any) => {
this.isConnected = false;
this.logger.error('Redis cache connection error', { error: error.message });
});
// this.redis.on('close', () => {
// this.isConnected = false;
// this.logger.warn('Redis cache connection closed');
// });
this.redis.on('close', () => {
this.isConnected = false;
this.logger.warn('Redis cache connection closed');
});
// this.redis.on('reconnecting', () => {
// this.logger.info('Redis cache reconnecting...');
// });
this.redis.on('reconnecting', () => {
this.logger.info('Redis cache reconnecting...');
});
}
private getKey(key: string): string {
console.log(`Using key prefix: ${this.keyPrefix}`);
return `${this.keyPrefix}${key}`;
}
@ -97,8 +96,8 @@ export class RedisCache implements CacheProvider {
operationName: string
): Promise<T> {
try {
if (!this.isConnected) {
this.logger.warn(`Redis not connected for ${operationName}, using fallback`);
if (!this.isReady()) {
this.logger.warn(`Redis not ready for ${operationName}, using fallback`);
this.updateStats(false, true);
return fallback;
}
@ -236,6 +235,6 @@ export class RedisCache implements CacheProvider {
}
isReady(): boolean {
return this.isConnected && this.redis.status === 'ready';
return this.redis.status === 'ready';
}
}