6#include <unordered_map>
8#include <userver/components/component_fwd.hpp>
9#include <userver/dynamic_config/snapshot.hpp>
10#include <userver/formats/json_fwd.hpp>
11#include <userver/yaml_config/fwd.hpp>
13USERVER_NAMESPACE_BEGIN
17enum class BackgroundUpdateMode {
22struct LruCacheConfig
final {
24 explicit LruCacheConfig(
const components::ComponentConfig& config);
26 explicit LruCacheConfig(
const formats::
json::Value& value);
28 std::size_t GetWaySize(std::size_t ways)
const;
31 std::chrono::milliseconds lifetime;
32 BackgroundUpdateMode background_update;
35LruCacheConfig Parse(
const formats::
json::Value& value,
36 formats::
parse::
To<LruCacheConfig>);
38struct LruCacheConfigStatic
final {
40 explicit LruCacheConfigStatic(
const components::ComponentConfig& config);
42 std::size_t GetWaySize()
const;
44 LruCacheConfig config;
46 bool use_dynamic_config;
49extern const dynamic_config::Key<
50 std::unordered_map<std::string, LruCacheConfig>>
53std::optional<LruCacheConfig> GetLruConfig(
54 const dynamic_config::Snapshot& config,
const std::string& cache_name);