userver: userver/cache/lru_cache_config.hpp Source File
Loading...
Searching...
No Matches
lru_cache_config.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <chrono>
7#include <cstddef>
8#include <optional>
9#include <unordered_map>
10
15
16USERVER_NAMESPACE_BEGIN
17
18namespace cache {
19
20enum class BackgroundUpdateMode {
21 kEnabled,
22 kDisabled,
23};
24
25struct LruCacheConfig final {
26 explicit LruCacheConfig(const yaml_config::YamlConfig& config);
27 explicit LruCacheConfig(const components::ComponentConfig& config);
28
29 explicit LruCacheConfig(const formats::json::Value& value);
30
31 std::size_t GetWaySize(std::size_t ways) const;
32
33 std::size_t size;
34 std::chrono::milliseconds lifetime;
35 BackgroundUpdateMode background_update;
36};
37
39
40struct LruCacheConfigStatic final {
41 explicit LruCacheConfigStatic(const yaml_config::YamlConfig& config);
42 explicit LruCacheConfigStatic(const components::ComponentConfig& config);
43
44 std::size_t GetWaySize() const;
45
46 LruCacheConfig config;
47 std::size_t ways;
48 bool use_dynamic_config;
49 bool wait_for_dynamic_configs;
50};
51
53
54std::optional<LruCacheConfig> GetLruConfig(const dynamic_config::Snapshot& config, const std::string& cache_name);
55
56} // namespace cache
57
58USERVER_NAMESPACE_END