fix: revoke session in shared cache before database to keep replicas consistent

This commit is contained in:
2026-11-01 14:57:41 +03:00
parent e9bc51288b
commit 53035d475f
4 changed files with 64 additions and 25 deletions
+16
View File
@@ -66,6 +66,22 @@ export class CacheService implements OnModuleDestroy {
}
}
async setStrict(key: string, value: string, ttlMs: number): Promise<boolean> {
if (!this.client) {
return true;
}
if (!this.trusted) {
return false;
}
try {
await this.client.set(key, value, 'PX', ttlMs);
return true;
} catch {
this.distrust();
return false;
}
}
onModuleDestroy(): void {
this.client?.disconnect();
}