Files
DeepTutor/web/lib/chat-workspaces-cache.ts

22 lines
606 B
TypeScript

import type { ChatWorkspaceRegistration } from "@/lib/workspaces-api";
let cached: { owner: string; rows: ChatWorkspaceRegistration[] } | null = null;
let generation = 0;
export function workspaceCacheGeneration() {
return generation;
}
export function readCachedChatWorkspaces(owner: string | null): ChatWorkspaceRegistration[] {
return owner && cached?.owner === owner ? cached.rows : [];
}
export function writeCachedChatWorkspaces(owner: string, rows: ChatWorkspaceRegistration[]) {
cached = { owner, rows };
}
export function resetChatWorkspacesCache() {
generation++;
cached = null;
}