diff options
| author | Per Larsson <[email protected]> | 2021-12-13 11:43:29 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-12-13 11:43:29 +0100 |
| commit | 7d8f6c99372c6157cc4db02d7c249985c789fc7d (patch) | |
| tree | 1a5527c9431d9382e0c48a06a626928c3bd745b5 /zenstore/gc.cpp | |
| parent | Added support for triggering GC with different params and refactored GC sched... (diff) | |
| download | zen-7d8f6c99372c6157cc4db02d7c249985c789fc7d.tar.xz zen-7d8f6c99372c6157cc4db02d7c249985c789fc7d.zip | |
Refactored z$ GC.
Diffstat (limited to 'zenstore/gc.cpp')
| -rw-r--r-- | zenstore/gc.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp index 8f08c8b1f..676374167 100644 --- a/zenstore/gc.cpp +++ b/zenstore/gc.cpp @@ -50,12 +50,14 @@ SaveCompactBinaryObject(const fs::path& Path, const CbObject& Object) struct GcContext::GcState { - 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; + 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; }; GcContext::GcContext(GcClock::TimePoint Time) : m_State(std::make_unique<GcState>()) @@ -80,6 +82,13 @@ GcContext::ContributeCas(std::span<const IoHash> Cas) } void +GcContext::ContributeCacheKeys(std::vector<IoHash> ValidKeys, std::vector<IoHash> ExpiredKeys) +{ + m_State->m_ValidCacheKeys = std::move(ValidKeys); + m_State->m_ExpiredCacheKeys = std::move(ExpiredKeys); +} + +void GcContext::IterateCids(std::function<void(const IoHash&)> Callback) { m_State->m_CidChunks.IterateChunks([&](const IoHash& Hash) { Callback(Hash); }); @@ -97,6 +106,18 @@ GcContext::FilterCas(std::span<const IoHash> Cas, std::function<void(const IoHas m_State->m_CasChunks.FilterChunks(Cas, [&](const IoHash& Hash) { KeepFunc(Hash); }); } +std::span<const IoHash> +GcContext::ValidCacheKeys() const +{ + return m_State->m_ValidCacheKeys; +} + +std::span<const IoHash> +GcContext::ExpiredCacheKeys() const +{ + return m_State->m_ExpiredCacheKeys; +} + bool GcContext::IsDeletionMode() const { |