7#include <userver/utils/statistics/recentperiod.hpp>
8#include <userver/utils/statistics/writer.hpp>
10USERVER_NAMESPACE_BEGIN
12namespace cache::
impl {
14struct ExpirableLruCacheStatisticsBase
final {
15 std::atomic<std::size_t> hits{0};
16 std::atomic<std::size_t> misses{0};
17 std::atomic<std::size_t> stale{0};
18 std::atomic<std::size_t> background_updates{0};
20 ExpirableLruCacheStatisticsBase();
22 ExpirableLruCacheStatisticsBase(
const ExpirableLruCacheStatisticsBase& other);
26 ExpirableLruCacheStatisticsBase& operator+=(
27 const ExpirableLruCacheStatisticsBase& other);
30struct ExpirableLruCacheStatistics
final {
31 ExpirableLruCacheStatisticsBase total;
32 utils::statistics::RecentPeriod<ExpirableLruCacheStatisticsBase,
33 ExpirableLruCacheStatisticsBase>
34 recent{std::chrono::seconds(5), std::chrono::seconds(60)};
37void CacheHit(ExpirableLruCacheStatistics& stats);
39void CacheMiss(ExpirableLruCacheStatistics& stats);
41void CacheStale(ExpirableLruCacheStatistics& stats);
43void DumpMetric(utils::statistics::Writer& writer,
44 const ExpirableLruCacheStatistics& stats);