new flat KV structure

This commit is contained in:
Pierre
2026-02-08 21:53:52 +01:00
parent 6cbfed5d1c
commit 942c06634a
4 changed files with 368 additions and 1 deletions
@@ -730,4 +730,38 @@ export class RedisClient implements Partial<IKVClient> {
getRawClient(): Redis | null {
return this.client;
}
/**
* Create a duplicate Redis connection for blocking stream consumers.
* Each blocking consumer needs its own connection since XREADGROUP blocks.
*
* The caller is responsible for closing this connection.
*/
createDuplicateConnection(): Redis | null {
if (!this.isConnected) {
logger.warn('Cannot create duplicate connection: not connected');
return null;
}
try {
const connection = new Redis(this.config.url, {
retryStrategy: (times: number) => {
if (times > 10) {
return null;
}
return Math.min(times * 500, 5000);
},
maxRetriesPerRequest: 3,
});
connection.on('error', (err: Error) => {
logger.error('Duplicate Redis connection error:', err.message);
});
return connection;
} catch (error) {
logger.error('Failed to create duplicate connection:', error);
return null;
}
}
}