#include <userver/cache/lru_cache_component_base.hpp>
Base class for LRU-cache components.
Provides facilities for creating LRU caches. You need to override LruCacheComponent::DoGetByKey to handle cache misses.
Caching components must be configured in service config (see options below) and may be reconfigured dynamically via components::DynamicConfig.
| Name | Description | Default value |
|---|---|---|
| size | max amount of items to store in cache | – |
| ways | number of ways for associative cache | – |
| lifetime | TTL for cache entries (0 is unlimited) | 0 |
| config-settings | enables dynamic reconfiguration with CacheConfigSet | true |
Do not forget to add the component to component list:
Definition at line 77 of file lru_cache_component_base.hpp.
Inheritance diagram for cache::LruCacheComponent< Key, Value, Hash, Equal >:
Collaboration diagram for cache::LruCacheComponent< Key, Value, Hash, Equal >:Public Types | |
| using | Cache = ExpirableLruCache<Key, Value, Hash, Equal> |
| using | CacheWrapper = LruCacheWrapper<Key, Value, Hash, Equal> |
Public Member Functions | |
| LruCacheComponent (const components::ComponentConfig &, const components::ComponentContext &) | |
| CacheWrapper | GetCache () |
Public Member Functions inherited from components::LoggableComponentBase | |
| LoggableComponentBase (const ComponentConfig &, const ComponentContext &) | |
| LoggableComponentBase (LoggableComponentBase &&)=delete | |
| LoggableComponentBase (const LoggableComponentBase &)=delete | |
| ~LoggableComponentBase () override=default | |
| ComponentHealth | GetComponentHealth () const override |
| void | OnLoadingCancelled () override |
| void | OnAllComponentsLoaded () override |
| void | OnAllComponentsAreStopping () override |
Static Public Member Functions | |
| static yaml_config::Schema | GetStaticConfigSchema () |
Static Public Member Functions inherited from components::LoggableComponentBase | |
| static yaml_config::Schema | GetStaticConfigSchema () |
Protected Member Functions | |
| virtual Value | DoGetByKey (const Key &key)=0 |
| std::shared_ptr< Cache > | GetCacheRaw () |
| using cache::LruCacheComponent< Key, Value, Hash, Equal >::Cache = ExpirableLruCache<Key, Value, Hash, Equal> |
Definition at line 80 of file lru_cache_component_base.hpp.
| using cache::LruCacheComponent< Key, Value, Hash, Equal >::CacheWrapper = LruCacheWrapper<Key, Value, Hash, Equal> |
Definition at line 81 of file lru_cache_component_base.hpp.
| cache::LruCacheComponent< Key, Value, Hash, Equal >::LruCacheComponent | ( | const components::ComponentConfig & | config, |
| const components::ComponentContext & | context ) |
Definition at line 125 of file lru_cache_component_base.hpp.
|
override |
Definition at line 164 of file lru_cache_component_base.hpp.
| LruCacheComponent< Key, Value, Hash, Equal >::CacheWrapper cache::LruCacheComponent< Key, Value, Hash, Equal >::GetCache | ( | ) |
Definition at line 176 of file lru_cache_component_base.hpp.
|
inlineprotected |
Definition at line 95 of file lru_cache_component_base.hpp.
|
static |
Definition at line 213 of file lru_cache_component_base.hpp.