aboutsummaryrefslogtreecommitdiff
path: root/zenstore/gc.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-12-13 14:01:04 +0100
committerPer Larsson <[email protected]>2021-12-13 14:01:04 +0100
commit4c58cfb3540bb64fd7fae72f1550b5b8d22d6878 (patch)
tree694a342308e47a8ad3e9610b03b434e71ec6d949 /zenstore/gc.cpp
parentMerge branch 'main' into gc (diff)
downloadzen-4c58cfb3540bb64fd7fae72f1550b5b8d22d6878.tar.xz
zen-4c58cfb3540bb64fd7fae72f1550b5b8d22d6878.zip
Fixed bug in z$ GC.
Diffstat (limited to 'zenstore/gc.cpp')
-rw-r--r--zenstore/gc.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp
index 676374167..bb26af87b 100644
--- a/zenstore/gc.cpp
+++ b/zenstore/gc.cpp
@@ -50,14 +50,21 @@ SaveCompactBinaryObject(const fs::path& Path, const CbObject& Object)
struct GcContext::GcState
{
- CasChunkSet m_CasChunks;
- CasChunkSet m_CidChunks;
- std::vector<IoHash> m_ValidCacheKeys;
- std::vector<IoHash> m_ExpiredCacheKeys;
- GcClock::TimePoint m_GcTime;
- GcClock::Duration m_MaxCacheDuration = std::chrono::hours(24);
- bool m_DeletionMode = true;
- bool m_CollectSmallObjects = false;
+ struct CacheBucket
+ {
+ std::vector<IoHash> ValidKeys;
+ std::vector<IoHash> ExpiredKeys;
+ };
+
+ using CacheBuckets = std::unordered_map<std::string, CacheBucket>;
+
+ CacheBuckets m_CacheBuckets;
+ CasChunkSet m_CasChunks;
+ CasChunkSet m_CidChunks;
+ GcClock::TimePoint m_GcTime;
+ GcClock::Duration m_MaxCacheDuration = std::chrono::hours(24);
+ bool m_DeletionMode = true;
+ bool m_CollectSmallObjects = false;
};
GcContext::GcContext(GcClock::TimePoint Time) : m_State(std::make_unique<GcState>())
@@ -82,10 +89,10 @@ GcContext::ContributeCas(std::span<const IoHash> Cas)
}
void
-GcContext::ContributeCacheKeys(std::vector<IoHash> ValidKeys, std::vector<IoHash> ExpiredKeys)
+GcContext::ContributeCacheKeys(const std::string& Bucket, std::vector<IoHash> ValidKeys, std::vector<IoHash> ExpiredKeys)
{
- m_State->m_ValidCacheKeys = std::move(ValidKeys);
- m_State->m_ExpiredCacheKeys = std::move(ExpiredKeys);
+ m_State->m_CacheBuckets[Bucket].ValidKeys = std::move(ValidKeys);
+ m_State->m_CacheBuckets[Bucket].ExpiredKeys = std::move(ExpiredKeys);
}
void
@@ -107,15 +114,15 @@ GcContext::FilterCas(std::span<const IoHash> Cas, std::function<void(const IoHas
}
std::span<const IoHash>
-GcContext::ValidCacheKeys() const
+GcContext::ValidCacheKeys(const std::string& Bucket) const
{
- return m_State->m_ValidCacheKeys;
+ return m_State->m_CacheBuckets[Bucket].ValidKeys;
}
std::span<const IoHash>
-GcContext::ExpiredCacheKeys() const
+GcContext::ExpiredCacheKeys(const std::string& Bucket) const
{
- return m_State->m_ExpiredCacheKeys;
+ return m_State->m_CacheBuckets[Bucket].ExpiredKeys;
}
bool