[SSE] Event stream TTL refresh (#17337)

This PR update the redis subscription iterator wrapper with an heartbeat
system. Heartbeat interval are based on event stream TTL. Those refresh
the event stream TTL and active streams in redis.

I also cleaned a few functions that were not used anymore.

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This commit is contained in:
Thomas Trompette
2026-01-22 14:32:59 +01:00
committed by GitHub
parent 6b63a28cd2
commit 8bf266626c
5 changed files with 144 additions and 80 deletions
@@ -245,6 +245,25 @@ export class CacheStorageService {
return newValue;
}
async expire(key: string, ttlMs: Milliseconds): Promise<boolean> {
if (this.isRedisCache()) {
return (this.cache as RedisCache).store.client.expire(
this.getKey(key),
ttlMs / 1000,
);
}
const existing = await this.get(key);
if (existing !== undefined) {
await this.set(key, existing, ttlMs);
return true;
}
return false;
}
private isRedisCache() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (this.cache.store as any)?.name === 'redis';