Loading...
Searching...
No Matches
EfPageCacheStorage Class Reference

Manages a page cache and provides methods for invalidation of cached values. More...

#include <pageCacheStorage.h>

Public Member Functions

EF_API ~EfPageCacheStorage ()
 Destructor.
 
EF_API bool IsEnabled () const
 Returns true if the storage is enabled, i.e.
 
EF_API void SetEnabled (bool enable)
 Enables / disables the storage.
 
EF_API const VdfRequest & GetCacheableRequest (const VdfRequest &request) const
 Given any request, returns another request containing the outputs, which are dependent on the key output, and thus can be committed to the page cache.
 
EF_API bool GetCachedKeys (const _CacheIteratorPredicateFunction &predicate, const VdfRequest &request, std::vector< const VdfVector * > *cachedKeys) const
 Returns the set of keys that have been cached in the pages selected by the predicate, as determined by the set of outputs contained in the request.
 
EF_API void Invalidate (const _CacheIteratorPredicateFunction &predicate)
 Invalidate the page cache by clearing the entire cache on the pages determined by the invalidation predicate.
 
EF_API void Invalidate (const _CacheIteratorPredicateFunction &predicate, const VdfMaskedOutputVector &invalidationRequest)
 Invalidate the page cache by clearing the output values dependent on the invalidationRequest, on the pages determined by the invalidation predicate.
 
EF_API void Clear ()
 Clear the entire cache on all pages.
 
EF_API void ClearNodes (const VdfNetwork &network, const tbb::concurrent_vector< VdfIndex > &nodes)
 Clears the output values associated with all the given nodes in the provided network.
 
EF_API void Resize (const VdfNetwork &network)
 Resizes the internal structures of the page cache to be able to accommodate output values for the provided network.
 
EF_API void WillDeleteNode (const VdfNode &node)
 Call this to notify the page cache storage of nodes that have been deleted from the network.
 

Static Public Member Functions

template<typename T >
static EfPageCacheStorageNew (const VdfMaskedOutput &keyMaskedOutput, EfLeafNodeCache *leafNodeCache)
 Constructor helper.
 
static EF_API size_t GetNumBytesUsed ()
 Returns the amount of memory currently used for cache storage, in bytes.
 
static EF_API size_t GetNumBytesLimit ()
 Returns the upper cache storage memory limit, in bytes.
 
static EF_API bool HasReachedMemoryLimit ()
 Returns true, if the upper memory limit has been reached, and the object is no longer allowed to allocate additional storage to cache new values.
 
static EF_API void SetMemoryUsageLimit (size_t bytes)
 Sets the upper memory limit, denoting how much memory this object is allowed to allocate.
 

Friends

template<template< typename > class E, typename D >
class EfPageCacheBasedExecutor
 
class EfPageCacheCommitRequest
 

Detailed Description

Manages a page cache and provides methods for invalidation of cached values.

Definition at line 43 of file pageCacheStorage.h.

Constructor & Destructor Documentation

◆ ~EfPageCacheStorage()

EF_API ~EfPageCacheStorage ( )

Destructor.

Member Function Documentation

◆ Clear()

EF_API void Clear ( )

Clear the entire cache on all pages.

◆ ClearNodes()

EF_API void ClearNodes ( const VdfNetwork network,
const tbb::concurrent_vector< VdfIndex > &  nodes 
)

Clears the output values associated with all the given nodes in the provided network.

◆ GetCacheableRequest()

EF_API const VdfRequest & GetCacheableRequest ( const VdfRequest &  request) const

Given any request, returns another request containing the outputs, which are dependent on the key output, and thus can be committed to the page cache.

◆ GetCachedKeys()

EF_API bool GetCachedKeys ( const _CacheIteratorPredicateFunction &  predicate,
const VdfRequest &  request,
std::vector< const VdfVector * > *  cachedKeys 
) const

Returns the set of keys that have been cached in the pages selected by the predicate, as determined by the set of outputs contained in the request.

Returns false if the request does not contain any cacheable outputs.

◆ GetNumBytesLimit()

static EF_API size_t GetNumBytesLimit ( )
static

Returns the upper cache storage memory limit, in bytes.

◆ GetNumBytesUsed()

static EF_API size_t GetNumBytesUsed ( )
static

Returns the amount of memory currently used for cache storage, in bytes.

◆ HasReachedMemoryLimit()

static EF_API bool HasReachedMemoryLimit ( )
static

Returns true, if the upper memory limit has been reached, and the object is no longer allowed to allocate additional storage to cache new values.

◆ Invalidate() [1/2]

EF_API void Invalidate ( const _CacheIteratorPredicateFunction &  predicate)

Invalidate the page cache by clearing the entire cache on the pages determined by the invalidation predicate.

◆ Invalidate() [2/2]

EF_API void Invalidate ( const _CacheIteratorPredicateFunction &  predicate,
const VdfMaskedOutputVector &  invalidationRequest 
)

Invalidate the page cache by clearing the output values dependent on the invalidationRequest, on the pages determined by the invalidation predicate.

◆ IsEnabled()

EF_API bool IsEnabled ( ) const

Returns true if the storage is enabled, i.e.

output values can be committed and retrieved from the cache.

◆ New()

EfPageCacheStorage * New ( const VdfMaskedOutput keyMaskedOutput,
EfLeafNodeCache leafNodeCache 
)
static

Constructor helper.

Use this to construct heap allocated instances of this class, with the given leafNodeCache.

Definition at line 257 of file pageCacheStorage.h.

◆ Resize()

EF_API void Resize ( const VdfNetwork network)

Resizes the internal structures of the page cache to be able to accommodate output values for the provided network.

Note
It's not thread-safe to Resize() while the page cache storage is concurrently being accessed.

◆ SetEnabled()

EF_API void SetEnabled ( bool  enable)

Enables / disables the storage.

◆ SetMemoryUsageLimit()

static EF_API void SetMemoryUsageLimit ( size_t  bytes)
static

Sets the upper memory limit, denoting how much memory this object is allowed to allocate.

◆ WillDeleteNode()

EF_API void WillDeleteNode ( const VdfNode node)

Call this to notify the page cache storage of nodes that have been deleted from the network.

Friends And Related Function Documentation

◆ EfPageCacheBasedExecutor

friend class EfPageCacheBasedExecutor
friend

Definition at line 47 of file pageCacheStorage.h.

◆ EfPageCacheCommitRequest

friend class EfPageCacheCommitRequest
friend

Definition at line 50 of file pageCacheStorage.h.


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