[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:
+19
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user