diff options
| author | Dan Engelbrecht <[email protected]> | 2023-11-07 22:25:44 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-07 22:25:44 +0100 |
| commit | 659f91a1102bc604e801b866e9a6b67f77fba6e4 (patch) | |
| tree | 2215a8e56512e8ace6f58783e8dc8dcc1f38b320 /src/zenserver/cache/structuredcachestore.cpp | |
| parent | factored out some compiler definitions etc into zenbase (#517) (diff) | |
| download | zen-659f91a1102bc604e801b866e9a6b67f77fba6e4.tar.xz zen-659f91a1102bc604e801b866e9a6b67f77fba6e4.zip | |
Don't put cache entries into the memory cache on Put, only on Get (#518)
Diffstat (limited to 'src/zenserver/cache/structuredcachestore.cpp')
| -rw-r--r-- | src/zenserver/cache/structuredcachestore.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/zenserver/cache/structuredcachestore.cpp b/src/zenserver/cache/structuredcachestore.cpp index 236a0e1d7..cc6fefc76 100644 --- a/src/zenserver/cache/structuredcachestore.cpp +++ b/src/zenserver/cache/structuredcachestore.cpp @@ -888,13 +888,24 @@ TEST_CASE("z$.size") IoBuffer Buffer = CacheValue.GetBuffer().AsIoBuffer(); Buffer.SetContentType(ZenContentType::kCbObject); + std::vector<std::pair<std::string, IoHash>> Keys; + for (size_t Key = 0; Key < Count; ++Key) { - const size_t Bucket = Key % 4; - Zcs.Put(fmt::format("test_bucket-{}", Bucket), - IoHash::HashBuffer(&Key, sizeof(uint32_t)), - ZenCacheValue{.Value = Buffer}, - {}); + const size_t Bucket = Key % 4; + std::string BucketName = fmt::format("test_bucket-{}", Bucket); + IoHash Hash = IoHash::HashBuffer(&Key, sizeof(uint32_t)); + Zcs.Put(BucketName, Hash, ZenCacheValue{.Value = Buffer}, {}); + Keys.push_back({BucketName, Hash}); + } + CacheSize = Zcs.StorageSize(); + CHECK_LE(CacheValue.GetSize() * Count, CacheSize.DiskSize); + CHECK_EQ(0, CacheSize.MemorySize); + + for (const auto& Key : Keys) + { + ZenCacheValue _; + Zcs.Get(Key.first, Key.second, _); } CacheSize = Zcs.StorageSize(); @@ -2359,6 +2370,11 @@ TEST_CASE("z$.newgc.basics") auto Attachments = CreateCompressedAttachment(CidStore, std::vector<size_t>{177, 1024 * 1024 * 2 + 31, 8999, 1024 * 1024 * 2 + 187}); IoHash CacheRecord = CreateCacheRecord(Zcs, CidStore, TearDrinkerBucket, Attachments); + { + // Do get so it ends up in memcache + ZenCacheValue _; + Zcs.Get(TearDrinkerBucket, CacheRecord, _); + } Zcs.SetAccessTime(TearDrinkerBucket, CacheRecord, GcClock::Now() - std::chrono::hours(2)); |