Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/mcp/src/shared-store.ts
T
2026-07-08 16:15:37 +02:00

22 lines
675 B
TypeScript

import { createSharedStore, type SharedStore } from "@hivegrid/shared-store";
let cachedStore: SharedStore | null = null;
let factory: () => SharedStore = () => createSharedStore({ namespace: "mcp", redisUrl: process.env.REDIS_URL });
export function getMcpSharedStore(): SharedStore {
if (cachedStore === null) {
cachedStore = factory();
}
return cachedStore;
}
export function __setMcpSharedStoreFactoryForTests(next: () => SharedStore): void {
factory = next;
cachedStore = null;
}
export function __resetMcpSharedStoreForTests(): void {
factory = () => createSharedStore({ namespace: "mcp", redisUrl: process.env.REDIS_URL });
cachedStore = null;
}