Class ISubBlockCacheControl#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Derived Type#

Class Documentation#

class ISubBlockCacheControl#

This interface defines the global operations on the cache. It is used to control the memory usage of the cache.

Subclassed by libCZI::ISubBlockCache

Public Functions

virtual void Prune(const PruneOptions &options) = 0#

Prunes the cache. This means that sub-blocks are removed from the cache until the cache satisfies the conditions given in the options. Note that the prune operation is not done automatically - it must be called manually. I.e. when adding an element to the cache, the cache is not pruned automatically.

Parameters:

options – Options for controlling the operation.

virtual ~ISubBlockCacheControl() = default#
ISubBlockCacheControl() = default#
ISubBlockCacheControl(const ISubBlockCacheControl&) = delete#
ISubBlockCacheControl &operator=(const ISubBlockCacheControl&) = delete#
ISubBlockCacheControl(ISubBlockCacheControl&&) noexcept = delete#
ISubBlockCacheControl &operator=(ISubBlockCacheControl&&) noexcept = delete#
struct PruneOptions#

Options for controlling the prune operation. There are two metrics which can be used to control what remains in the cache and what is discarded: the maximum memory usage (for all elements in the cache) and the maximum number of sub-blocks. If the cache exceeds one of those limits, then elements are evicted from the cache until both conditions are met. Eviction is done in the order starting with elements which have been least recently accessed. As “access” we define either the Add-operation or the Get-operation - so, when an element is retrieved from the cache, it is considered as “accessed”. If only one condition is desired, then the other condition can be set to the maximum value of the respective type (which is the default value).

Public Members

std::uint64_t maxMemoryUsage = {(std::numeric_limits<decltype(maxMemoryUsage)>::max)()}#

The maximum memory usage (in bytes) for the cache. If the cache exceeds this limit, then the least recently used sub-blocks are removed from the cache.

std::uint32_t maxSubBlockCount = {(std::numeric_limits<decltype(maxSubBlockCount)>::max)()}#

The maximum number of sub-blocks in the cache. If the cache exceeds this limit, then the least recently used sub-blocks are removed from the cache.