aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcachestore.h
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-25 13:49:58 +0200
committerDan Engelbrecht <[email protected]>2022-05-25 13:57:21 +0200
commitd0c46ee88f3b08c0abc4f1cfba40b966f3c6a59e (patch)
tree5740aaffe74a648bcee0631fb997581991d18565 /zenserver/cache/structuredcachestore.h
parentMerge pull request #106 from EpicGames/de/safer-delete-cache-bucket (diff)
downloadzen-d0c46ee88f3b08c0abc4f1cfba40b966f3c6a59e.tar.xz
zen-d0c46ee88f3b08c0abc4f1cfba40b966f3c6a59e.zip
Make sure ZenCacheMemoryLayer handles dropped buckets correctly (just like ZenCacheDiskLayer)
Diffstat (limited to 'zenserver/cache/structuredcachestore.h')
-rw-r--r--zenserver/cache/structuredcachestore.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/zenserver/cache/structuredcachestore.h b/zenserver/cache/structuredcachestore.h
index 311e062be..4da48d3d9 100644
--- a/zenserver/cache/structuredcachestore.h
+++ b/zenserver/cache/structuredcachestore.h
@@ -150,6 +150,7 @@ public:
bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
void Put(std::string_view Bucket, const IoHash& HashKey, const ZenCacheValue& Value);
+ void Drop();
bool DropBucket(std::string_view Bucket);
void Scrub(ScrubContext& Ctx);
void GatherAccessTimes(zen::access_tracking::AccessTimes& AccessTimes);
@@ -193,14 +194,16 @@ private:
bool Get(const IoHash& HashKey, ZenCacheValue& OutValue);
void Put(const IoHash& HashKey, const ZenCacheValue& Value);
+ void Drop();
void Scrub(ScrubContext& Ctx);
void GatherAccessTimes(std::vector<zen::access_tracking::KeyAccessTime>& AccessTimes);
inline uint64_t TotalSize() const { return m_TotalSize; }
};
- mutable RwLock m_Lock;
- std::unordered_map<std::string, CacheBucket> m_Buckets;
- Configuration m_Configuration;
+ mutable RwLock m_Lock;
+ std::unordered_map<std::string, std::unique_ptr<CacheBucket>> m_Buckets;
+ std::vector<std::unique_ptr<CacheBucket>> m_DroppedBuckets;
+ Configuration m_Configuration;
ZenCacheMemoryLayer(const ZenCacheMemoryLayer&) = delete;
ZenCacheMemoryLayer& operator=(const ZenCacheMemoryLayer&) = delete;
@@ -214,6 +217,7 @@ public:
bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
void Put(std::string_view Bucket, const IoHash& HashKey, const ZenCacheValue& Value);
+ bool Drop();
bool DropBucket(std::string_view Bucket);
void Flush();
void Scrub(ScrubContext& Ctx);
@@ -236,7 +240,7 @@ private:
bool OpenOrCreate(std::filesystem::path BucketDir, bool AllowCreate = true);
bool Get(const IoHash& HashKey, ZenCacheValue& OutValue);
void Put(const IoHash& HashKey, const ZenCacheValue& Value);
- void Drop();
+ bool Drop();
void Flush();
void Scrub(ScrubContext& Ctx);
void GatherReferences(GcContext& GcCtx);