diff --git a/src/GameCult.Caching.MessagePack/CultCacheMessagePack.cs b/src/GameCult.Caching.MessagePack/CultCacheMessagePack.cs
index 16bbd6c9..02ee32d5 100644
--- a/src/GameCult.Caching.MessagePack/CultCacheMessagePack.cs
+++ b/src/GameCult.Caching.MessagePack/CultCacheMessagePack.cs
@@ -29,36 +29,10 @@ namespace GameCult.Caching.MessagePack
///
public bool StoreFlushOnDispose { get; set; }
- ///
- /// Gets or sets an optional callback used to customize the cache before opening.
- ///
- public Action? ConfigureCache { get; set; }
-
- ///
- /// Gets or sets an optional callback used to customize the backing store before opening.
- ///
- public Action? ConfigureStore { get; set; }
-
///
/// Gets or sets whether the cache should use a paged directory store instead of one whole-file snapshot.
///
public bool UseDirectoryStore { get; set; }
-
- ///
- /// Gets or sets the directory used for paged records. When omitted, the store uses the file path plus ".records".
- ///
- public string? DirectoryStorePath { get; set; }
-
- ///
- /// 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.
- ///
- public Func? DirectoryStoreHydrationFilter { get; set; }
-
- ///
- /// Gets or sets an optional callback used to customize the directory backing store before opening.
- ///
- public Action? ConfigureDirectoryStore { get; set; }
}
///
@@ -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;
diff --git a/tests/GameCult.Caching.Tests/BackingStoreTests.cs b/tests/GameCult.Caching.Tests/BackingStoreTests.cs
index 483007cb..c2eb95f4 100644
--- a/tests/GameCult.Caching.Tests/BackingStoreTests.cs
+++ b/tests/GameCult.Caching.Tests/BackingStoreTests.cs
@@ -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(hot.Key)?.Value, Is.EqualTo("hydrate-me"));
- Assert.That(selected.Get(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(hot.Key)?.Value, Is.EqualTo("hydrate-me"));
Assert.That(reopened.Get(cold.Key)?.Value.Length, Is.EqualTo(1024 * 1024));
- Assert.That(reopened.GetAll().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
{