Delete unused CultCacheOpenOptions callbacks and directory overrides

ConfigureCache, ConfigureStore, DirectoryStorePath, DirectoryStoreHydrationFilter
and ConfigureDirectoryStore had no consumer outside tests. CreateCore attaches
the directory store at its default record path, or the single-file store,
with no customization hooks. OpenAsync keeps its behavior (pull, then
materialize missing globals); PullOnOpen stays until Cut 3.

The indexed-filter test loses its selective-open half and keeps the v4
manifest assertions: the hot index carries only the SHA-256 page identity and
both records reload.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-13 16:45:42 +02:00
commit 59410fc474
2 changed files with 8 additions and 67 deletions

View file

@ -29,36 +29,10 @@ namespace GameCult.Caching.MessagePack
/// </summary>
public bool StoreFlushOnDispose { get; set; }
/// <summary>
/// Gets or sets an optional callback used to customize the cache before opening.
/// </summary>
public Action<CultCache>? ConfigureCache { get; set; }
/// <summary>
/// Gets or sets an optional callback used to customize the backing store before opening.
/// </summary>
public Action<SingleFileMessagePackBackingStore>? ConfigureStore { get; set; }
/// <summary>
/// Gets or sets whether the cache should use a paged directory store instead of one whole-file snapshot.
/// </summary>
public bool UseDirectoryStore { get; set; }
/// <summary>
/// Gets or sets the directory used for paged records. When omitted, the store uses the file path plus ".records".
/// </summary>
public string? DirectoryStorePath { get; set; }
/// <summary>
/// Gets or sets the records to hydrate when opening a paged directory store.
/// The directory manifest is always read; rejected record payloads are never opened.
/// </summary>
public Func<CultPersistedRecordMetadata, bool>? DirectoryStoreHydrationFilter { get; set; }
/// <summary>
/// Gets or sets an optional callback used to customize the directory backing store before opening.
/// </summary>
public Action<DirectoryMessagePackBackingStore>? ConfigureDirectoryStore { get; set; }
}
/// <summary>
@ -106,26 +80,20 @@ namespace GameCult.Caching.MessagePack
{
FlushAttachedStoresOnDispose = options.FlushOnDispose
};
options.ConfigureCache?.Invoke(cache);
if (options.UseDirectoryStore || Directory.Exists(options.DirectoryStorePath ?? DirectoryMessagePackBackingStore.DefaultRecordDirectoryPath(filePath)))
if (options.UseDirectoryStore || Directory.Exists(DirectoryMessagePackBackingStore.DefaultRecordDirectoryPath(filePath)))
{
var directoryStore = new DirectoryMessagePackBackingStore(filePath, options.DirectoryStorePath)
cache.AddBackingStore(new DirectoryMessagePackBackingStore(filePath)
{
FlushOnDispose = options.StoreFlushOnDispose,
HydrationFilter = options.DirectoryStoreHydrationFilter
};
options.ConfigureDirectoryStore?.Invoke(directoryStore);
cache.AddBackingStore(directoryStore);
FlushOnDispose = options.StoreFlushOnDispose
});
}
else
{
var store = new SingleFileMessagePackBackingStore(filePath)
cache.AddBackingStore(new SingleFileMessagePackBackingStore(filePath)
{
FlushOnDispose = options.StoreFlushOnDispose
};
options.ConfigureStore?.Invoke(store);
cache.AddBackingStore(store);
});
}
return cache;

View file

@ -360,7 +360,7 @@ namespace GameCult.Caching.Tests
}
[Test]
public async Task DirectoryMessagePackBackingStore_IndexedFilter_DoesNotOpenOrDeleteColdPayloads()
public async Task DirectoryMessagePackBackingStore_Manifest_Indexes_Pages_By_Content_Hash_Only()
{
var filePath = Path.Combine(Path.GetTempPath(), $"cultlib-tests-{Guid.NewGuid():N}.cc");
var recordsPath = DirectoryMessagePackBackingStore.DefaultRecordDirectoryPath(filePath);
@ -388,38 +388,11 @@ namespace GameCult.Caching.Tests
Assert.That(manifest.Records.All(record => record.Payload.Length == 32), Is.True,
"the hot index carries only the SHA-256 page identity, never the document body");
var coldPath = Directory.GetFiles(recordsPath, "*.msgpack")
.Single(path => string.Equals(
CultDocumentMessagePackSerialization.DeserializePersistedRecord(File.ReadAllBytes(path)).Key,
cold.Key.Value,
StringComparison.Ordinal));
using (new FileStream(coldPath, FileMode.Open, FileAccess.Read, FileShare.None))
using (var selected = await CultCacheMessagePack.OpenAsync(
filePath,
new CultCacheOpenOptions
{
UseDirectoryStore = true,
DirectoryStoreHydrationFilter = metadata =>
string.Equals(metadata.Key, hot.Key.Value, StringComparison.Ordinal)
}))
{
Assert.That(selected.Get<NamedTestEntry>(hot.Key)?.Value, Is.EqualTo("hydrate-me"));
Assert.That(selected.Get<NamedTestEntry>(cold.Key), Is.Null);
await selected.UpsertAsync(new NamedTestEntry { Name = "new", Value = "persist-with-cold-page-locked" });
await selected.FlushAsync();
}
using var reopened = await CultCacheMessagePack.OpenAsync(
filePath,
new CultCacheOpenOptions { UseDirectoryStore = true });
Assert.That(reopened.Get<NamedTestEntry>(hot.Key)?.Value, Is.EqualTo("hydrate-me"));
Assert.That(reopened.Get<NamedTestEntry>(cold.Key)?.Value.Length, Is.EqualTo(1024 * 1024));
Assert.That(reopened.GetAll<NamedTestEntry>().Count(), Is.EqualTo(3));
var finalManifest = CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(filePath));
Assert.That(finalManifest.Records, Has.Length.EqualTo(3));
Assert.That(finalManifest.Records.Any(record => record.Key == cold.Key.Value), Is.True);
Assert.That(finalManifest.Records.All(record => record.Payload.Length == 32), Is.True);
}
finally
{