diff options
Diffstat (limited to 'zenstore')
| -rw-r--r-- | zenstore/gc.cpp | 37 | ||||
| -rw-r--r-- | zenstore/include/zenstore/gc.h | 6 |
2 files changed, 25 insertions, 18 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 diff --git a/zenstore/include/zenstore/gc.h b/zenstore/include/zenstore/gc.h index 995453d47..fe93456c6 100644 --- a/zenstore/include/zenstore/gc.h +++ b/zenstore/include/zenstore/gc.h @@ -51,15 +51,15 @@ public: void ContributeCids(std::span<const IoHash> Cid); void ContributeCas(std::span<const IoHash> Hash); - void ContributeCacheKeys(std::vector<IoHash> ValidKeys, std::vector<IoHash> ExpiredKeys); + void ContributeCacheKeys(const std::string& Bucket, std::vector<IoHash> ValidKeys, std::vector<IoHash> ExpiredKeys); void IterateCids(std::function<void(const IoHash&)> Callback); void FilterCids(std::span<const IoHash> Cid, std::function<void(const IoHash&)> KeepFunc); void FilterCas(std::span<const IoHash> Cas, std::function<void(const IoHash&)> KeepFunc); - std::span<const IoHash> ValidCacheKeys() const; - std::span<const IoHash> ExpiredCacheKeys() const; + std::span<const IoHash> ValidCacheKeys(const std::string& Bucket) const; + std::span<const IoHash> ExpiredCacheKeys(const std::string& Bucket) const; bool IsDeletionMode() const; void SetDeletionMode(bool NewState); |