Skip to content

Commit cbe6ac9

Browse files
committed
fix(data): persist write-refreshed values and update in-memory LRU on restore
Write replies that refresh on-screen reads called adopt() but never save(), so confirmed values stayed out of persistent cache. After reload within the fresh window the store showed pre-write data. Add the missing save() call after adopt in confirm's refreshed-entry path, matching load() and adoptSeed(). Restoring an entry only pushed an updated lastUsed into the storage put list; the in-memory metas map kept the previous timestamp, so purge() could evict a just-restored value before older unused entries. Update metas in place so purge sees the current session's access order.
1 parent bba3ec8 commit cbe6ac9

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎packages/octane/src/data/persist.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,11 @@ export function createPersistence(
326326
}
327327
for (const name of touched) {
328328
const meta = metas.get(name);
329-
if (meta) put.push({ meta: { ...meta, lastUsed: now } });
329+
if (meta) {
330+
const updated = { ...meta, lastUsed: now };
331+
metas.set(name, updated);
332+
put.push({ meta: updated });
333+
}
330334
}
331335
touched.clear();
332336
purge(now);

‎packages/octane/src/data/store.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ export function createDataStore(options: DataStoreOptions): DataStore {
973973
(value) => () => {
974974
if (!current()) return undefined;
975975
adopt(entry, value, startedSeq);
976+
save(entry);
976977
return entry;
977978
},
978979
() => () => {

0 commit comments

Comments
 (0)