Files
Twitch-VOD-Manager/src/main/domain/last-good-cache.ts
T
Sucukdeluxe 9f1b052afd Release Twitch VOD Manager 1.0.18
Harden update, system-check, queue, cutter, streamer and shutdown state transitions.

Add multi-user installer recovery, secret-safe config migration, provider fallback handling, managed-tool validation and real media export coverage.

Refresh the English public documentation, release notes and 1.0.18 product screenshot.
2026-08-13 22:59:15 +02:00

26 lines
768 B
TypeScript

export class LastGoodCache<T> {
private readonly values = new Map<string, T>();
constructor(private readonly maxEntries: number) {
if (!Number.isSafeInteger(maxEntries) || maxEntries < 1) throw new Error('maxEntries must be a positive integer');
}
get(key: string): T | undefined {
return this.values.get(key);
}
set(key: string, value: T): void {
this.values.delete(key);
this.values.set(key, value);
while (this.values.size > this.maxEntries) {
const oldest = this.values.keys().next().value as string | undefined;
if (!oldest) break;
this.values.delete(oldest);
}
}
delete(key: string): boolean {
return this.values.delete(key);
}
}