mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-05 07:09:56 +08:00
22 lines
606 B
TypeScript
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;
|
|
}
|