From fdcd769a821adb03b3cf79bb873fe46dfeb02e55 Mon Sep 17 00:00:00 2001 From: Per Larsson Date: Tue, 7 Dec 2021 11:06:22 +0100 Subject: Added support for time based eviction policy in structured cache. --- zenstore/gc.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'zenstore/gc.cpp') diff --git a/zenstore/gc.cpp b/zenstore/gc.cpp index b18a577bf..5aff20e7a 100644 --- a/zenstore/gc.cpp +++ b/zenstore/gc.cpp @@ -47,14 +47,17 @@ SaveCompactBinaryObject(const std::filesystem::path& Path, const CbObject& Objec struct GcContext::GcState { - CasChunkSet m_CasChunks; - CasChunkSet m_CidChunks; - bool m_DeletionMode = true; - bool m_ContainerGcEnabled = false; + CasChunkSet m_CasChunks; + CasChunkSet m_CidChunks; + GcClock::TimePoint m_GcTime; + GcClock::Duration m_MaxCacheDuration = std::chrono::hours(24); + bool m_DeletionMode = true; + bool m_ContainerGcEnabled = false; }; -GcContext::GcContext() : m_State(std::make_unique()) +GcContext::GcContext(GcClock::TimePoint Time) : m_State(std::make_unique()) { + m_State->m_GcTime = Time; } GcContext::~GcContext() @@ -115,6 +118,24 @@ GcContext::SetContainerGcEnabled(bool NewState) m_State->m_ContainerGcEnabled = NewState; } +GcClock::TimePoint +GcContext::Time() const +{ + return m_State->m_GcTime; +} + +GcClock::Duration +GcContext::MaxCacheDuration() const +{ + return m_State->m_MaxCacheDuration; +} + +void +GcContext::MaxCacheDuration(GcClock::Duration Duration) +{ + m_State->m_MaxCacheDuration = Duration; +} + ////////////////////////////////////////////////////////////////////////// GcContributor::GcContributor(CasGc& Gc) : m_Gc(Gc) -- cgit v1.2.3