CultCache: every backing store marks the records it rewrites, through a protected CacheBackingStore.MarkWritten

The directory store's write of a generation marks each page it wrote once the
manifest names it, so a Push+PushAll of a loaded drifted entry no longer leaves
its persisted schema id stale. The single-file store marks through the same
member, and a store outside GameCult.Caching now has a supported way to mark
its own rewrite. The getter's doc names how a store records a rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-21 21:41:53 +02:00
commit 73d438dbcf
3 changed files with 24 additions and 5 deletions

View file

@ -263,6 +263,7 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
var keysToWrite = _dirtyKeys.Keys
.OrderBy(value => value, StringComparer.Ordinal)
.ToArray();
var written = new List<CultStoredDocument>(keysToWrite.Length);
foreach (var key in keysToWrite)
{
if (!Entries.TryGetValue(key, out var stored))
@ -281,11 +282,15 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
WriteFileAtomically(
ContentAddressedRecordPath(indexRecord),
pagePayload);
written.Add(stored);
}
WriteManifest(targetCatalog, currentIndex.Values
.OrderBy(record => record.Key, StringComparer.Ordinal)
.ToArray());
// The manifest names the new pages: each was written under its own descriptor.
foreach (var stored in written)
MarkWritten(stored);
DeleteUnreferencedRecordPages(currentIndex.Values);