userver: cache::UpdateStatisticsScope Class Reference
Loading...
Searching...
No Matches
cache::UpdateStatisticsScope Class Referencefinal

#include <userver/cache/cache_statistics.hpp>

Detailed Description

Allows a specific cache to fill cache statistics during an Update.

If Update returns without throwing an exception and without calling one of the Finish* methods, the behavior is undefined.

See components::CachingComponentBase::Set() for information on actual cache update, rather than statistics update.

Examples
samples/http_caching/http_caching.cpp.

Definition at line 57 of file cache_statistics.hpp.

Public Member Functions

void Finish (std::size_t total_documents_count)
 Mark that the Update has finished with changes.
 
void FinishNoChanges ()
 Mark that the Update has finished without changes.
 
void FinishWithError ()
 Mark that the Update failed.
 
void IncreaseDocumentsReadCount (std::size_t add)
 Each item received from the data source should be accounted with this function.
 
void IncreaseDocumentsParseFailures (std::size_t add)
 Each received item that failed validation should be accounted with this function, in addition to IncreaseDocumentsReadCount.
 

Member Function Documentation

◆ Finish()

void cache::UpdateStatisticsScope::Finish ( std::size_t total_documents_count)

Mark that the Update has finished with changes.

Parameters
documents_countthe new total number of items stored in the cache
Examples
samples/http_caching/http_caching.cpp.

◆ IncreaseDocumentsParseFailures()

void cache::UpdateStatisticsScope::IncreaseDocumentsParseFailures ( std::size_t add)

Each received item that failed validation should be accounted with this function, in addition to IncreaseDocumentsReadCount.

Note
This method can be called multiple times per Update
Parameters
addthe number of non-valid items newly received

◆ IncreaseDocumentsReadCount()

void cache::UpdateStatisticsScope::IncreaseDocumentsReadCount ( std::size_t add)

Each item received from the data source should be accounted with this function.

Note
This method can be called multiple times per Update
Parameters
addthe number of items (both valid and non-valid) newly received
Examples
samples/http_caching/http_caching.cpp.

The documentation for this class was generated from the following file: