diff options
author | osidorkin <osidorkin@yandex-team.com> | 2024-10-11 19:49:49 +0300 |
---|---|---|
committer | osidorkin <osidorkin@yandex-team.com> | 2024-10-11 19:59:49 +0300 |
commit | 8bf978732bcddc47f4423a69687172990b04ae10 (patch) | |
tree | f1e488115934c103a62c3ac1aee4e18af3cf9d44 | |
parent | 4b65bbe0c0af2054762b6ed9ddfd1e15160aca00 (diff) | |
download | ydb-8bf978732bcddc47f4423a69687172990b04ae10.tar.gz |
YT-23122: Ping replication card residency cache during long polling
commit_hash:c0a5fdf40615a88982a47b87a772293b506e6687
-rw-r--r-- | yt/yt/core/misc/async_expiring_cache-inl.h | 21 | ||||
-rw-r--r-- | yt/yt/core/misc/async_expiring_cache.h | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/yt/yt/core/misc/async_expiring_cache-inl.h b/yt/yt/core/misc/async_expiring_cache-inl.h index bad6d0a399..eb520f4dff 100644 --- a/yt/yt/core/misc/async_expiring_cache-inl.h +++ b/yt/yt/core/misc/async_expiring_cache-inl.h @@ -343,6 +343,27 @@ void TAsyncExpiringCache<TKey, TValue>::ForceRefresh(const TKey& key, const T& v } template <class TKey, class TValue> +void TAsyncExpiringCache<TKey, TValue>::PingEntry(const TKey& key) +{ + auto now = NProfiling::GetCpuInstant(); + auto guard = ReaderGuard(SpinLock_); + + if (auto it = Map_.find(key); it != Map_.end() && it->second->Promise.IsSet()) { + const auto& entry = it->second; + if (!entry->Promise.Get().IsOK()) { + return; + } + + entry->AccessDeadline = now + NProfiling::DurationToCpuDuration(Config()->ExpireAfterAccessTime); + entry->UpdateDeadline = now + NProfiling::DurationToCpuDuration(Config()->ExpireAfterSuccessfulUpdateTime); + if (!Config()->BatchUpdate) { + ScheduleEntryRefresh(entry, key, Config_->RefreshTime); + } + + } +} + +template <class TKey, class TValue> void TAsyncExpiringCache<TKey, TValue>::Set(const TKey& key, TErrorOr<TValue> valueOrError) { auto isValueOK = valueOrError.IsOK(); diff --git a/yt/yt/core/misc/async_expiring_cache.h b/yt/yt/core/misc/async_expiring_cache.h index 137df01f32..913849ecd1 100644 --- a/yt/yt/core/misc/async_expiring_cache.h +++ b/yt/yt/core/misc/async_expiring_cache.h @@ -92,6 +92,9 @@ protected: virtual bool CanCacheError(const TError& error) noexcept; + //! PingEntry resets refresh timer period and behaves like successful entry update. + void PingEntry(const TKey& key); + private: const NLogging::TLogger Logger_; |