Soft flush: the reader's own answer decides (no second stat, protocol default included); pin the readable-empty store, spy the flag through Mesh and host, changelog the breaking PushAll
Some checks failed
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Has been cancelled
Some checks failed
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Has been cancelled
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fb80e32749
commit
80eed16c0d
9 changed files with 170 additions and 19 deletions
|
|
@ -87,6 +87,36 @@ namespace GameCult.Caching.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SoftFlush_Over_Readable_Store_Holding_No_Records_Leaves_It()
|
||||
{
|
||||
var filePath = Path.Combine(Path.GetTempPath(), $"cultlib-tests-{Guid.NewGuid():N}.msgpack");
|
||||
try
|
||||
{
|
||||
var store = new SingleFileMessagePackBackingStore(filePath);
|
||||
var cache = new CultCache();
|
||||
cache.AddBackingStore(store);
|
||||
var first = await cache.AddAsync(new NamedTestEntry { Name = "first", Value = "one" });
|
||||
await cache.FlushAsync();
|
||||
cache.Remove(first.Key);
|
||||
await cache.FlushAsync();
|
||||
var before = File.ReadAllBytes(filePath);
|
||||
var empty = new CultCache();
|
||||
empty.AddBackingStore(new SingleFileMessagePackBackingStore(filePath));
|
||||
Assert.That(empty.AllEntries, Is.Empty, "the store is not readable-empty");
|
||||
|
||||
await cache.AddAsync(new NamedTestEntry { Name = "second", Value = "two" });
|
||||
await cache.FlushAsync(soft: true);
|
||||
|
||||
Assert.That(File.ReadAllBytes(filePath), Is.EqualTo(before), "a soft flush wrote over a readable store that holds no records");
|
||||
Assert.That(store.IsDirty, Is.True);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(filePath)) File.Delete(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PlainPushAll_Over_Readable_Store_Writes_The_Staged_Records()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue