fixes for redis event memory leak
This commit is contained in:
parent
9825e99540
commit
fdb8823df7
2 changed files with 39 additions and 14 deletions
18
libs/cache/src/redis-cache.ts
vendored
18
libs/cache/src/redis-cache.ts
vendored
|
|
@ -42,7 +42,13 @@ export class RedisCache implements CacheProvider {
|
|||
singleton: options.shared ?? true, // Default to shared connection for cache
|
||||
});
|
||||
|
||||
this.setupEventHandlers();
|
||||
// Only setup event handlers for non-shared connections to avoid memory leaks
|
||||
if (!(options.shared ?? true)) {
|
||||
this.setupEventHandlers();
|
||||
} else {
|
||||
// For shared connections, just monitor the connection status without adding handlers
|
||||
this.isConnected = this.redis.status === 'ready';
|
||||
}
|
||||
}
|
||||
|
||||
private setupEventHandlers(): void {
|
||||
|
|
@ -235,6 +241,14 @@ export class RedisCache implements CacheProvider {
|
|||
}
|
||||
|
||||
isReady(): boolean {
|
||||
return this.redis.status === 'ready';
|
||||
// Always check the actual Redis connection status
|
||||
const ready = this.redis.status === 'ready';
|
||||
|
||||
// Update local flag if we're not using shared connection
|
||||
if (this.isConnected !== ready) {
|
||||
this.isConnected = ready;
|
||||
}
|
||||
|
||||
return ready;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue