2026-09-09 14:02:26 +08:00
|
|
|
import type { UIMessage } from "./types";
|
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-09-12 04:37:37 +08:00
|
|
|
export class ThreadMessageCache extends MemoryLruCache<UIMessage[]> {
|
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
|
|
|
}
|
|
|
|
|
}
|