Base class for LRU-cache components. More...
#include <userver/cache/lru_cache_component_base.hpp>
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 () |
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 80 of file lru_cache_component_base.hpp.
using cache::LruCacheComponent< Key, Value, Hash, Equal >::Cache = ExpirableLruCache<Key, Value, Hash, Equal> |
Definition at line 83 of file lru_cache_component_base.hpp.
using cache::LruCacheComponent< Key, Value, Hash, Equal >::CacheWrapper = LruCacheWrapper<Key, Value, Hash, Equal> |
Definition at line 84 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 127 of file lru_cache_component_base.hpp.
|
override |
Definition at line 168 of file lru_cache_component_base.hpp.
LruCacheComponent< Key, Value, Hash, Equal >::CacheWrapper cache::LruCacheComponent< Key, Value, Hash, Equal >::GetCache | ( | ) |
Definition at line 180 of file lru_cache_component_base.hpp.
|
inlineprotected |
Definition at line 114 of file lru_cache_component_base.hpp.
|
static |
Definition at line 217 of file lru_cache_component_base.hpp.