userver
C++ Async Framework
Loading...
Searching...
No Matches
lru_cache_config.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/cache/lru_cache_config.hpp
4
/// @brief LRU cache configuration types and dynamic config integration
5
6
#
include
<
chrono
>
7
#
include
<
cstddef
>
8
#
include
<
optional
>
9
#
include
<
unordered_map
>
10
11
#
include
<
userver
/
components
/
component_fwd
.
hpp
>
12
#
include
<
userver
/
dynamic_config
/
snapshot
.
hpp
>
13
#
include
<
userver
/
formats
/
json_fwd
.
hpp
>
14
#
include
<
userver
/
yaml_config
/
fwd
.
hpp
>
15
16
USERVER_NAMESPACE_BEGIN
17
18
namespace
cache
{
19
20
enum
class
BackgroundUpdateMode {
21
kEnabled,
22
kDisabled,
23
};
24
25
struct
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
38
LruCacheConfig Parse(
const
formats::json::
Value
& value, formats::
parse
::To<LruCacheConfig>);
39
40
struct
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
};
50
51
extern
const
dynamic_config::Key<std::unordered_map<std::string, LruCacheConfig>> kLruCacheConfigSet;
52
53
std::optional<LruCacheConfig> GetLruConfig(
const
dynamic_config::Snapshot& config,
const
std::string& cache_name);
54
55
}
// namespace cache
56
57
USERVER_NAMESPACE_END
userver
cache
lru_cache_config.hpp
Generated on Thu May 21 2026 16:18:04 for userver by
Doxygen
1.13.2