#include <userver/cache/base_mongo_cache.hpp>
The traits define the query (GetFindOperation or kUseDefaultFindOperation), so the method has a default implementation.
Definition at line 77 of file base_mongo_cache.hpp.
Public Types | |
| using | DataType |
| using | DataType |
Public Member Functions | |
| const std::string & | Name () const noexcept |
| void | InvalidateAsync (UpdateType update_type) |
| Non-blocking forced cache update of specified type. | |
| void | InvalidateAsync (UpdateType update_type) |
| Non-blocking forced cache update of specified type. | |
| utils::SharedReadablePtr< MongoCacheTraits::DataType > | Get () const final |
| utils::SharedReadablePtr< MongoCacheTraits::DataType > | GetUnsafe () const |
| concurrent::AsyncEventSubscriberScope | UpdateAndListen (Class *obj, std::string name, void(Class::*func)(const std::shared_ptr< const MongoCacheTraits::DataType > &)) |
| concurrent::AsyncEventChannel< const std::shared_ptr< const MongoCacheTraits::DataType > & > & | GetEventChannel () |
| ComponentHealth | GetComponentHealth () const override |
| void | OnLoadingCancelled () override |
| void | OnAllComponentsLoaded () override |
| void | OnGracefulShutdown (engine::Deadline serving_shutdown_deadline) override |
| void | OnAllComponentsAreStopping () override |
| void | UpdateSyncDebug (UpdateType update_type) |
| Forces a synchronous cache update of specified type. | |
| const std::string & | Name () const noexcept |
| void | InvalidateAsync (UpdateType update_type) |
| Non-blocking forced cache update of specified type. | |
| void | InvalidateAsync (UpdateType update_type) |
| Non-blocking forced cache update of specified type. | |
| utils::SharedReadablePtr< MongoCacheTraits::DataType > | Get () const final |
| utils::SharedReadablePtr< MongoCacheTraits::DataType > | GetUnsafe () const |
| concurrent::AsyncEventSubscriberScope | UpdateAndListen (Class *obj, std::string name, void(Class::*func)(const std::shared_ptr< const MongoCacheTraits::DataType > &)) |
| concurrent::AsyncEventChannel< const std::shared_ptr< const MongoCacheTraits::DataType > & > & | GetEventChannel () |
| ComponentHealth | GetComponentHealth () const override |
| void | OnLoadingCancelled () override |
| void | OnAllComponentsLoaded () override |
| void | OnGracefulShutdown (engine::Deadline serving_shutdown_deadline) override |
| void | OnAllComponentsAreStopping () override |
| void | UpdateSyncDebug (UpdateType update_type) |
| Forces a synchronous cache update of specified type. | |
| void | UpdateSyncDebug (UpdateType update_type) |
| Forces a synchronous cache update of specified type. | |
Static Public Member Functions | |
| static yaml_config::Schema | GetStaticConfigSchema () |
| static yaml_config::Schema | GetStaticConfigSchema () |
Protected Types | |
| using | LoggableComponentBase |
| enum | Flag |
| Periodic update flags. More... | |
| using | LoggableComponentBase |
| enum | Flag |
| Periodic update flags. More... | |
Protected Member Functions | |
| MongoCacheFindOperationBase (const ComponentConfig &config, const ComponentContext &context) | |
| virtual storages::mongo::operations::Find | MakeFindOperation (cache::UpdateType type, const std::chrono::system_clock::time_point &last_update, const std::chrono::system_clock::time_point &now, const std::chrono::system_clock::duration &correction) |
| void | Set (std::unique_ptr< const MongoCacheTraits::DataType > value_ptr) |
| Sets the new value of cache. As a result, Get member function starts returning the new value. | |
| void | Attach (const std::shared_ptr< const MongoCacheTraits::DataType > &value_ptr) |
| void | Emplace (Args &&... args) |
| void | Clear () |
| Clears the content of the cache by string a default constructed T. | |
| virtual bool | MayReturnNull () const |
| Whether Get is expected to return nullptr. | |
| virtual void | PreAssignCheck (const MongoCacheTraits::DataType *old_value_ptr, const MongoCacheTraits::DataType *new_value_ptr) const |
| If the option has-pre-assign-check is set true in static config, this function is called before assigning the new value to the cache. | |
| void | UpdateSyncDebug (UpdateType update_type) |
| Forces a synchronous cache update of specified type. | |
| AllowedUpdateTypes | GetAllowedUpdateTypes () const |
| Update types configured for the cache. | |
| void | OnCacheModified () noexcept |
| virtual void | Update (UpdateType type, const std::chrono::system_clock::time_point &last_update, const std::chrono::system_clock::time_point &now, UpdateStatisticsScope &stats_scope)=0 |
| Should be overridden in a derived class to align the stored data with some data source. | |
| virtual utils::Flags< Flag > | GetStartFlags () const |
| Returns flags for cache start. | |
| void | EarlyStartPeriodicUpdates (utils::Flags< Flag > flags) |
| Call this to start periodic updates just now, not after the constructor. | |
| void | EarlyStartPeriodicUpdates (utils::Flags< Flag > flags) |
| Call this to start periodic updates just now, not after the constructor. | |
| void | Set (std::unique_ptr< const MongoCacheTraits::DataType > value_ptr) |
| Sets the new value of cache. As a result, Get member function starts returning the new value. | |
| void | Attach (const std::shared_ptr< const MongoCacheTraits::DataType > &value_ptr) |
| void | Emplace (Args &&... args) |
| void | Clear () |
| Clears the content of the cache by string a default constructed T. | |
| virtual bool | MayReturnNull () const |
| Whether Get is expected to return nullptr. | |
| virtual void | PreAssignCheck (const MongoCacheTraits::DataType *old_value_ptr, const MongoCacheTraits::DataType *new_value_ptr) const |
| If the option has-pre-assign-check is set true in static config, this function is called before assigning the new value to the cache. | |
| AllowedUpdateTypes | GetAllowedUpdateTypes () const |
| Update types configured for the cache. | |
| void | OnCacheModified () noexcept |
| virtual void | Update (UpdateType type, const std::chrono::system_clock::time_point &last_update, const std::chrono::system_clock::time_point &now, UpdateStatisticsScope &stats_scope)=0 |
| Should be overridden in a derived class to align the stored data with some data source. | |
| virtual utils::Flags< Flag > | GetStartFlags () const |
| Returns flags for cache start. | |
| void | EarlyStartPeriodicUpdates (utils::Flags< Flag > flags) |
| Call this to start periodic updates just now, not after the constructor. | |
| void | EarlyStartPeriodicUpdates (utils::Flags< Flag > flags) |
| Call this to start periodic updates just now, not after the constructor. | |
| virtual void | WriteContents (dump::Writer &writer, const MongoCacheTraits::DataType &contents) const |
| virtual std::unique_ptr< const MongoCacheTraits::DataType > | ReadContents (dump::Reader &reader) const |
| virtual void | WriteContents (dump::Writer &writer, const MongoCacheTraits::DataType &contents) const |
| virtual std::unique_ptr< const MongoCacheTraits::DataType > | ReadContents (dump::Reader &reader) const |
|
inherited |
Definition at line 144 of file caching_component_base.hpp.
| using components::CachingComponentBase< MongoCacheTraits::DataType >::DataType |
Definition at line 144 of file caching_component_base.hpp.
|
protectedinherited |
Definition at line 79 of file component_base.hpp.
|
protected |
Definition at line 79 of file component_base.hpp.
|
strongprotectedinherited |
Periodic update flags.
Definition at line 89 of file cache_update_trait.hpp.
|
strongprotected |
Periodic update flags.
Definition at line 89 of file cache_update_trait.hpp.
|
inlineprotected |
Definition at line 79 of file base_mongo_cache.hpp.
|
protectedinherited |
Attach the value of cache. As a result the Get() member function starts returning the value passed into this function after the Update() finishes. Does not take over into sole ownership. Do not use unless absolutely necessary. The object must be strictly thread-safe.
Definition at line 186 of file caching_component_base.hpp.
|
protected |
Attach the value of cache. As a result the Get() member function starts returning the value passed into this function after the Update() finishes. Does not take over into sole ownership. Do not use unless absolutely necessary. The object must be strictly thread-safe.
Definition at line 186 of file caching_component_base.hpp.
|
protectedinherited |
Clears the content of the cache by string a default constructed T.
Definition at line 193 of file caching_component_base.hpp.
|
protected |
Clears the content of the cache by string a default constructed T.
Definition at line 193 of file caching_component_base.hpp.
|
protectedinherited |
Definition at line 190 of file caching_component_base.hpp.
|
protected |
Definition at line 190 of file caching_component_base.hpp.
|
finalvirtualinherited |
| cache::EmptyCacheError | if the contents are nullptr, and MayReturnNull returns false (which is the default behavior). |
Implements cache::DataProvider< MongoCacheTraits::DataType >.
Definition at line 150 of file caching_component_base.hpp.
|
final |
| cache::EmptyCacheError | if the contents are nullptr, and MayReturnNull returns false (which is the default behavior). |
Definition at line 150 of file caching_component_base.hpp.
|
inlineoverrideinherited |
Override this function to inform the world of the state of your component.
Definition at line 35 of file component_base.hpp.
|
inlineoverride |
Override this function to inform the world of the state of your component.
Definition at line 35 of file component_base.hpp.
|
inherited |
Definition at line 164 of file caching_component_base.hpp.
| concurrent::AsyncEventChannel< const std::shared_ptr< const MongoCacheTraits::DataType > & > & components::CachingComponentBase< MongoCacheTraits::DataType >::GetEventChannel | ( | ) |
Definition at line 164 of file caching_component_base.hpp.
|
staticinherited |
Definition at line 166 of file caching_component_base.hpp.
|
static |
Definition at line 166 of file caching_component_base.hpp.
|
inherited |
Definition at line 153 of file caching_component_base.hpp.
| utils::SharedReadablePtr< MongoCacheTraits::DataType > components::CachingComponentBase< MongoCacheTraits::DataType >::GetUnsafe | ( | ) | const |
Definition at line 153 of file caching_component_base.hpp.
|
inherited |
Non-blocking forced cache update of specified type.
|
inherited |
Non-blocking forced cache update of specified type.
| void cache::CacheUpdateTrait::InvalidateAsync | ( | UpdateType | update_type | ) |
Non-blocking forced cache update of specified type.
| ( | UpdateType | update_type | ) |
Non-blocking forced cache update of specified type.
|
inlineprotectedvirtual |
Definition at line 83 of file base_mongo_cache.hpp.
|
protectedvirtualinherited |
Whether Get is expected to return nullptr.
Definition at line 196 of file caching_component_base.hpp.
|
protectedvirtual |
Whether Get is expected to return nullptr.
Definition at line 196 of file caching_component_base.hpp.
|
inherited |
| ( | ) | const |
|
inlineoverrideinherited |
Component may use this function to stop doing work before the stop of the components that depend on it.
Base components may override it and make final to do some work before the derived object constructor is called. Don't use it otherwise.
Definition at line 70 of file component_base.hpp.
|
inlineoverride |
Component may use this function to stop doing work before the stop of the components that depend on it.
Base components may override it and make final to do some work before the derived object constructor is called. Don't use it otherwise.
Definition at line 70 of file component_base.hpp.
|
inlineoverrideinherited |
Component may use this function to finalize registration of other components that depend on it (for example, handler components register in server component, and the latter uses OnAllComponentsLoaded() to start processing requests).
Base components may override it and make final to do some work after the derived object constructor is called. Don't use it otherwise.
Definition at line 51 of file component_base.hpp.
|
inlineoverride |
Component may use this function to finalize registration of other components that depend on it (for example, handler components register in server component, and the latter uses OnAllComponentsLoaded() to start processing requests).
Base components may override it and make final to do some work after the derived object constructor is called. Don't use it otherwise.
Definition at line 51 of file component_base.hpp.
|
protectednoexceptinherited |
Called in CachingComponentBase::Set during update to indicate that the cached data has been modified
|
protectednoexcept |
Called in CachingComponentBase::Set during update to indicate that the cached data has been modified
|
overrideinherited |
Serving components like HTTP and gRPC servers may use this function to stop accepting new requests and shutdown serving in the given time interval. Application components likely do not need to override it.
| [in] | serving_shutdown_deadline | The deadline until already running requests should be allowed to complete. The component is supposed to stop accepting new requests and continue processing of already active requests until this deadline (unless those requests finish earlier). And it might completely shutdown requests processing when the deadline is reached (or when no active requests left). |
|
override |
Serving components like HTTP and gRPC servers may use this function to stop accepting new requests and shutdown serving in the given time interval. Application components likely do not need to override it.
| [in] | serving_shutdown_deadline | The deadline until already running requests should be allowed to complete. The component is supposed to stop accepting new requests and continue processing of already active requests until this deadline (unless those requests finish earlier). And it might completely shutdown requests processing when the deadline is reached (or when no active requests left). |
|
inlineoverrideinherited |
Called once if the creation of any other component failed. If the current component expects some other component to take any action with the current component, this call is a signal that such action may never happen due to components loading was cancelled. Application components might not want to override it.
Definition at line 42 of file component_base.hpp.
|
inlineoverride |
Called once if the creation of any other component failed. If the current component expects some other component to take any action with the current component, this call is a signal that such action may never happen due to components loading was cancelled. Application components might not want to override it.
Definition at line 42 of file component_base.hpp.
|
protectedvirtualinherited |
If the option has-pre-assign-check is set true in static config, this function is called before assigning the new value to the cache.
Definition at line 208 of file caching_component_base.hpp.
|
protectedvirtual |
If the option has-pre-assign-check is set true in static config, this function is called before assigning the new value to the cache.
Definition at line 208 of file caching_component_base.hpp.
|
protectedvirtualinherited |
Definition at line 202 of file caching_component_base.hpp.
|
protectedvirtual |
Definition at line 202 of file caching_component_base.hpp.
|
protectedinherited |
Sets the new value of cache. As a result, Get member function starts returning the new value.
Notifies subscribers after setting the new value, see UpdateAndListen. Should only be called from Update normally.
Definition at line 175 of file caching_component_base.hpp.
|
protected |
Sets the new value of cache. As a result, Get member function starts returning the new value.
Notifies subscribers after setting the new value, see UpdateAndListen. Should only be called from Update normally.
Definition at line 175 of file caching_component_base.hpp.
|
protectedpure virtualinherited |
Should be overridden in a derived class to align the stored data with some data source.
Update implementation should do one of the following:
A. If the update succeeded and has changes...
B. If the update succeeded and verified that there are no changes...
C. If the update failed...
| type | type of the update |
| last_update | time of the last update (value of now from previous invocation of Update or default constructed value if this is the first Update). |
| now | current time point |
| stats_scope | the scope that expects one of Finish, FinishNoChanges, FinishWithError or an exception. |
| std::exception | on update failure |
|
protectedpure virtual |
Should be overridden in a derived class to align the stored data with some data source.
Update implementation should do one of the following:
A. If the update succeeded and has changes...
B. If the update succeeded and verified that there are no changes...
C. If the update failed...
| type | type of the update |
| last_update | time of the last update (value of now from previous invocation of Update or default constructed value if this is the first Update). |
| now | current time point |
| stats_scope | the scope that expects one of Finish, FinishNoChanges, FinishWithError or an exception. |
| std::exception | on update failure |
|
inherited |
Subscribes to cache updates using a member function. Also immediately invokes the function with the current cache contents.
Definition at line 158 of file caching_component_base.hpp.
| concurrent::AsyncEventSubscriberScope components::CachingComponentBase< MongoCacheTraits::DataType >::UpdateAndListen | ( | Class * | obj, |
| std::string | name, | ||
| void(Class::* | func )(const std::shared_ptr< const MongoCacheTraits::DataType > &) ) |
Subscribes to cache updates using a member function. Also immediately invokes the function with the current cache contents.
Definition at line 158 of file caching_component_base.hpp.
|
inherited |
Forces a synchronous cache update of specified type.
| If | Update throws |
|
inherited |
Forces a synchronous cache update of specified type.
| If | Update throws |
| void cache::CacheUpdateTrait::UpdateSyncDebug | ( | UpdateType | update_type | ) |
Forces a synchronous cache update of specified type.
| If | Update throws |
| void cache::CacheUpdateTrait::UpdateSyncDebug | ( | UpdateType | update_type | ) |
Forces a synchronous cache update of specified type.
| If | Update throws |
|
protectedvirtualinherited |
Override to use custom serialization for cache dumps
Definition at line 200 of file caching_component_base.hpp.
|
protectedvirtual |
Override to use custom serialization for cache dumps
Definition at line 200 of file caching_component_base.hpp.