Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
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";
|
||||
* is reused across the API lifetime.
|
||||
*/
|
||||
let cachedStore: SharedStore | null = null;
|
||||
let crossAppCacheStore: SharedStore | null = null;
|
||||
let factory: () => SharedStore = () => createSharedStore({ namespace: "api", redisUrl: process.env.REDIS_URL });
|
||||
|
||||
export function getSharedStore(): SharedStore {
|
||||
@@ -16,6 +17,18 @@ export function getSharedStore(): SharedStore {
|
||||
return cachedStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared namespace for cache invalidations exchanged with other apps. It
|
||||
* reuses this process's adapter/connection while making the wire channel
|
||||
* independent from the app-local `api` namespace.
|
||||
*/
|
||||
export function getCrossAppCacheStore(): SharedStore {
|
||||
if (crossAppCacheStore === null) {
|
||||
crossAppCacheStore = createSharedStore({ namespace: "cross-app-cache", adapter: getSharedStore().adapter });
|
||||
}
|
||||
return crossAppCacheStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test seam: override the factory and clear the cached instance. Tests
|
||||
* call this to inject a SharedStore that uses an in-memory adapter or a
|
||||
@@ -24,10 +37,12 @@ export function getSharedStore(): SharedStore {
|
||||
export function __setSharedStoreFactoryForTests(next: () => SharedStore): void {
|
||||
factory = next;
|
||||
cachedStore = null;
|
||||
crossAppCacheStore = null;
|
||||
}
|
||||
|
||||
/** Test seam: reset to the default factory and drop the cached instance. */
|
||||
export function __resetSharedStoreForTests(): void {
|
||||
factory = () => createSharedStore({ namespace: "api", redisUrl: process.env.REDIS_URL });
|
||||
cachedStore = null;
|
||||
crossAppCacheStore = null;
|
||||
}
|
||||
Reference in new issue
Block a user