core::PersistentCacheStats Class Reference

Class that provides (read-only) access to cache statistics and settings. More...

`#include <core/persistent_cache_stats.h>`

## Public Member Functions

Construction, Copy and Assignment
Copy and assignment have the usual value semantics. The default constructor creates an instance with an empty cache path, `lru_only` policy, and the remaining values set to zero.
| PersistentCacheStats ()
| PersistentCacheStats (PersistentCacheStats const &)
| PersistentCacheStats (PersistentCacheStats &&) noexcept
PersistentCacheStats & | operator= (PersistentCacheStats const &)
PersistentCacheStats & | operator= (PersistentCacheStats &&)

## Accessors

typedef std::vector< uint32_t > | Histogram
| Histogram of the size distribution of cache entries. More...
typedef std::vector< std::pair< int32_t, int32_t > > | HistogramBounds
| Lower and upper bounds for the bins in the histogram. More...
static constexpr unsigned | NUM_BINS = 74
| The number of bins in a histogram. More...
std::string | cache_path () const
| Returns the path to the cache directory. More...
CacheDiscardPolicy | policy () const noexcept
| Returns the discard policy (`lru_only` or `lru_ttl`). More...
int64_t | size () const noexcept
| Returns the number of entries (including expired ones). More...
int64_t | size_in_bytes () const noexcept
| Returns the size of all entries (including expired ones). More...
int64_t | max_size_in_bytes () const noexcept
| Returns the maximum size of the cache. More...
int64_t | hits () const noexcept
| Returns the number of hits since the statistics were last reset. More...
int64_t | misses () const noexcept
| Returns the number of misses since the statistics were last reset. More...
int64_t | hits_since_last_miss () const noexcept
| Returns the number of consecutive hits since the last miss. More...
int64_t | misses_since_last_hit () const noexcept
| Returns the number of consecutive misses since the last hit. More...
int64_t | longest_hit_run () const noexcept
| Returns the largest number of consecutive hits. More...
int64_t | longest_miss_run () const noexcept
| Returns the largest number of consecutive misses. More...
int64_t | hit_runs () const noexcept
| Returns the number of hit runs. More...
int64_t | miss_runs () const noexcept
| Returns the number of miss runs. More...
double | avg_hit_run_length () const noexcept
| Returns a rolling average of the hit run length. More...
double | avg_miss_run_length () const noexcept
| Returns a rolling average of the miss run length. More...
int64_t | ttl_evictions () const noexcept
| Returns the number of entries that were evicted due to being expired. More...
int64_t | lru_evictions () const noexcept
| Returns the number of entries that were evicted due to being least recently used. More...
std::chrono::system_clock::time_point | most_recent_hit_time () const noexcept
| Returns the timestamp of the most recent hit. More...
std::chrono::system_clock::time_point | most_recent_miss_time () const noexcept
| Returns the timestamp of the most recent miss. More...
std::chrono::system_clock::time_point | longest_hit_run_time () const noexcept
| Returns the time of the longest hit run. More...
std::chrono::system_clock::time_point | longest_miss_run_time () const noexcept
| Returns the time of the longest miss run. More...
Histogram const & | histogram () const noexcept
| Returns a histogram for the entries in the cache. More...
static HistogramBounds const & | histogram_bounds () noexcept
| Returns the bounds for each bin a histogram. More...

## Detailed Description

Class that provides (read-only) access to cache statistics and settings.

## Member Typedef Documentation

typedef std::vector<uint32_t> core::PersistentCacheStats::Histogram

Histogram of the size distribution of cache entries.

The histogram uses a logarithmic scale and contains the number of entries in the cache, with entries grouped by size into a number of bins as follows:

Index | Entry size in bytes
--- | ---
0 | 1..9
1 | 10..19
2 | 20..29
... | ...
9 | 90..99
10 | 100..199
11 | 200..200
... | ...
18 | 900..999
19 | 1,000..1,999
20 | 2,000..2,999
... | ...
27 | 9,000..9,999
28 | 10,000..19,999
29 | 20,000..29,999
... | ...
72 | 900,000,000..999,999,999
73 | 1,000,000,000..

Index 0 contains the number of entries < 10 bytes. Thereafter, the histogram contains 9 bins for each power of 10, plus a final bin at index 73 that contains the number of entries ≥ 109 bytes.

typedef std::vector<std::pair<int32_t, int32_t> > core::PersistentCacheStats::HistogramBounds

Lower and upper bounds for the bins in the histogram.

Each pair contains the lower and upper (inclusive) bound of the corresponding bin of the values returned by histogram().

## Constructor & Destructor Documentation

core::PersistentCacheStats::PersistentCacheStats | ( |  | ) |

core::PersistentCacheStats::PersistentCacheStats | ( | PersistentCacheStats const & |  | ) |

core::PersistentCacheStats::PersistentCacheStats | ( | PersistentCacheStats && |  | ) |

noexcept

## Member Function Documentation

double core::PersistentCacheStats::avg_hit_run_length | ( |  | ) | const

noexcept

Returns a rolling average of the hit run length.

double core::PersistentCacheStats::avg_miss_run_length | ( |  | ) | const

noexcept

Returns a rolling average of the miss run length.

std::string core::PersistentCacheStats::cache_path | ( |  | ) | const

Returns the path to the cache directory.

Histogram const& core::PersistentCacheStats::histogram | ( |  | ) | const

noexcept

Returns a histogram for the entries in the cache.

static HistogramBounds const& core::PersistentCacheStats::histogram_bounds | ( |  | ) |

static noexcept

Returns the bounds for each bin a histogram.

This method returns the same vector each time; it is provided as a convenience method to make it easier to add labels to a histogram for display. The returned pairs use inclusive ranges, that is, `pair.second` is the largest possible size of the bin.

int64_t core::PersistentCacheStats::hit_runs | ( |  | ) | const

noexcept

Returns the number of hit runs.

int64_t core::PersistentCacheStats::hits | ( |  | ) | const

noexcept

Returns the number of hits since the statistics were last reset.

int64_t core::PersistentCacheStats::hits_since_last_miss | ( |  | ) | const

noexcept

Returns the number of consecutive hits since the last miss.

int64_t core::PersistentCacheStats::longest_hit_run | ( |  | ) | const

noexcept

Returns the largest number of consecutive hits.

std::chrono::system_clock::time_point core::PersistentCacheStats::longest_hit_run_time | ( |  | ) | const

noexcept

Returns the time of the longest hit run.

int64_t core::PersistentCacheStats::longest_miss_run | ( |  | ) | const

noexcept

Returns the largest number of consecutive misses.

std::chrono::system_clock::time_point core::PersistentCacheStats::longest_miss_run_time | ( |  | ) | const

noexcept

Returns the time of the longest miss run.

int64_t core::PersistentCacheStats::lru_evictions | ( |  | ) | const

noexcept

Returns the number of entries that were evicted due to being least recently used.

int64_t core::PersistentCacheStats::max_size_in_bytes | ( |  | ) | const

noexcept

Returns the maximum size of the cache.

int64_t core::PersistentCacheStats::miss_runs | ( |  | ) | const

noexcept

Returns the number of miss runs.

int64_t core::PersistentCacheStats::misses | ( |  | ) | const

noexcept

Returns the number of misses since the statistics were last reset.

int64_t core::PersistentCacheStats::misses_since_last_hit | ( |  | ) | const

noexcept

Returns the number of consecutive misses since the last hit.

std::chrono::system_clock::time_point core::PersistentCacheStats::most_recent_hit_time | ( |  | ) | const

noexcept

Returns the timestamp of the most recent hit.

std::chrono::system_clock::time_point core::PersistentCacheStats::most_recent_miss_time | ( |  | ) | const

noexcept

Returns the timestamp of the most recent miss.

PersistentCacheStats& core::PersistentCacheStats::operator= | ( | PersistentCacheStats const & |  | ) |

PersistentCacheStats& core::PersistentCacheStats::operator= | ( | PersistentCacheStats && |  | ) |

CacheDiscardPolicy core::PersistentCacheStats::policy | ( |  | ) | const

noexcept

Returns the discard policy (`lru_only` or `lru_ttl`).

int64_t core::PersistentCacheStats::size | ( |  | ) | const

noexcept

Returns the number of entries (including expired ones).

int64_t core::PersistentCacheStats::size_in_bytes | ( |  | ) | const

noexcept

Returns the size of all entries (including expired ones).

int64_t core::PersistentCacheStats::ttl_evictions | ( |  | ) | const

noexcept

Returns the number of entries that were evicted due to being expired.

## Member Data Documentation

constexpr unsigned core::PersistentCacheStats::NUM_BINS = 74

static

The number of bins in a histogram.

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

- /build/persistent-cache-cpp-6lGcHa/persistent-cache-cpp-1.0.4+16.04.20160117/include/core/persistent_cache_stats.h