2026-10-21 18:30:52 +08:00
|
|
|
import type { ThreadCheckpoint } from "./thread-checkpoint";
|
2026-09-12 04:37:37 +08:00
|
|
|
import { MemoryLruCache } from "./memory-lru-cache";
|
2026-09-09 14:02:26 +08:00
|
|
|
|
|
|
|
|
/** Bounded replay cache; temporary chats remain pinned because they have no disk history. */
|
2026-10-21 18:30:52 +08:00
|
|
|
export class ThreadMessageCache<T extends ThreadCheckpoint = ThreadCheckpoint> extends MemoryLruCache<T> {
|
2026-09-09 14:02:26 +08:00
|
|
|
|
|
|
|
|
constructor(
|
2026-09-12 04:37:37 +08:00
|
|
|
isPinned: (key: string) => boolean,
|
|
|
|
|
maxBytes = 16 * 1024 * 1024,
|
|
|
|
|
maxEntries = 12,
|
|
|
|
|
) {
|
|
|
|
|
super(maxBytes, maxEntries, (key) => !isPinned(key));
|
2026-09-09 14:02:26 +08:00
|
|
|
}
|
|
|
|
|
}
|