mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-08-06 15:10:13 +00:00
Align web vault updates with resource sync
This commit is contained in:
@@ -51,6 +51,29 @@ export async function invalidateVaultCoreSyncSnapshot(cacheKey: string): Promise
|
||||
await clearCachedVaultCoreSnapshot(normalizedKey);
|
||||
}
|
||||
|
||||
export async function saveVaultCoreSyncSnapshot(
|
||||
cacheKey: string,
|
||||
snapshot: VaultCoreSnapshot,
|
||||
revisionStamp?: number | null
|
||||
): Promise<void> {
|
||||
const normalizedKey = String(cacheKey || '').trim();
|
||||
if (!normalizedKey) return;
|
||||
|
||||
const normalizedSnapshot = normalizeCachedSnapshot(snapshot);
|
||||
const currentMemory = memoryVaultCoreCache.get(normalizedKey);
|
||||
let nextRevisionStamp = Number(revisionStamp);
|
||||
if (!Number.isFinite(nextRevisionStamp) || nextRevisionStamp <= 0) {
|
||||
const cached = await loadCachedVaultCoreSnapshot(normalizedKey);
|
||||
nextRevisionStamp = currentMemory?.revisionStamp || cached?.revisionStamp || Date.now();
|
||||
}
|
||||
|
||||
memoryVaultCoreCache.set(normalizedKey, {
|
||||
revisionStamp: nextRevisionStamp,
|
||||
snapshot: normalizedSnapshot,
|
||||
});
|
||||
await saveCachedVaultCoreSnapshot(normalizedKey, nextRevisionStamp, normalizedSnapshot);
|
||||
}
|
||||
|
||||
export async function loadVaultCoreSyncSnapshot(authedFetch: AuthedFetch, cacheKey: string): Promise<VaultCoreSnapshot> {
|
||||
const normalizedKey = String(cacheKey || '').trim();
|
||||
if (!normalizedKey) return { ciphers: [], folders: [], sends: [] };
|
||||
|
||||
Reference in New Issue
Block a user