Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -7,6 +7,7 @@ import { createSharedStore, type SharedStore } from "@hivegrid/shared-store";
* reused across the web lifetime.
*/
let cachedStore: SharedStore | null = null;
let crossAppCacheStore: SharedStore | null = null;
let factory: () => SharedStore = () => createSharedStore({ namespace: "web", redisUrl: process.env.REDIS_URL });
export function getSharedStore(): SharedStore {
@@ -16,12 +17,38 @@ export function getSharedStore(): SharedStore {
return cachedStore;
}
/** Shared cache-invalidation namespace used by both the API and web apps. */
export function getCrossAppCacheStore(): SharedStore {
if (crossAppCacheStore === null) {
crossAppCacheStore = createSharedStore({ namespace: "cross-app-cache", adapter: getSharedStore().adapter });
}
return crossAppCacheStore;
}
/** Close the singleton adapter for short-lived processes such as DB seeding. */
export async function closeSharedStores(): Promise<void> {
const stores = [cachedStore, crossAppCacheStore].filter((store): store is SharedStore => store !== null);
cachedStore = null;
crossAppCacheStore = null;
const seenAdapters = new Set<SharedStore["adapter"]>();
await Promise.all(
stores.map(async (store) => {
if (seenAdapters.has(store.adapter)) return;
seenAdapters.add(store.adapter);
await store.close();
}),
);
}
export function __setSharedStoreFactoryForTests(next: () => SharedStore): void {
factory = next;
cachedStore = null;
crossAppCacheStore = null;
}
export function __resetSharedStoreForTests(): void {
factory = () => createSharedStore({ namespace: "web", redisUrl: process.env.REDIS_URL });
cachedStore = null;
crossAppCacheStore = null;
}