HDK
|
#include <UT_CappedCache.h>
Public Member Functions | |
UT_CappedCache (const char *name, int64 size_in_mb=32) | |
~UT_CappedCache () override | |
UT_CappedCache (const UT_CappedCache &)=delete | |
UT_CappedCache & | operator= (const UT_CappedCache &)=delete |
void | clear () |
Clear the cache. More... | |
exint | entries () const |
Number of entries in the cache. More... | |
exint | getListEntries () const |
UT_CappedItemHandle | findItem (const UT_CappedKey &key) |
Find an item in the cache. More... | |
UT_CappedItemHandle | addItem (const UT_CappedKey &key, const UT_CappedItemHandle &item) |
void | deleteItem (const UT_CappedKey &key) |
Remove an item from the cache. More... | |
template<typename T > | |
void | threadSafeTraversal (T &task) |
const char * | utGetCacheName () const override |
bool | utHasMaxSize () const override |
int64 | utGetCurrentSize () const override |
int64 | utGetMaxSize () const override |
void | utSetMaxSize (int64 bytes) override |
int64 | utReduceCacheSizeBy (int64 bytes) override |
Public Member Functions inherited from UT_Cache | |
UT_Cache () | |
virtual | ~UT_Cache () |
UT_Cache (const UT_Cache &)=delete | |
UT_Cache & | operator= (const UT_Cache &)=delete |
void | utClearCache () |
virtual bool | utHasMinSize () const |
virtual int64 | utGetMinSize () const |
virtual void | utSetMinSize (int64) |
virtual bool | utUpdateCacheInfo () |
Additional Inherited Members | |
Static Public Member Functions inherited from UT_Cache | |
static const UT_ValArray < UT_Cache * > & | utGetCacheList () |
get the list of caches More... | |
static void | setCacheAddRemoveCB (void(*callback)(void *), void *data) |
callback to be called when a cache is added or deleted. More... | |
static int64 | utClearSpaceFromCaches (int64 amount) |
this method attempts to free up 'amount' bytes from all the caches. More... | |
A thread safe memory limited cache
This class stores a map of UT_CappedItem objects which are queried by UT_CappedKey objects. In addition, the cache is an LRU, memory limited cache. The cache tracks memory used by each UT_CappedItem to keep memory usage limited to the given threshold.
Definition at line 75 of file UT_CappedCache.h.
UT_CappedCache::UT_CappedCache | ( | const char * | name, |
int64 | size_in_mb = 32 |
||
) |
|
override |
|
delete |
UT_CappedItemHandle UT_CappedCache::addItem | ( | const UT_CappedKey & | key, |
const UT_CappedItemHandle & | item | ||
) |
Add an item to the cache. The returned item may not be the item passed as an argument. This may happen if two threads attempt to add the same item at the same time (i.e. the keys are equivalent, but the items may be different).
void UT_CappedCache::clear | ( | ) |
Clear the cache.
void UT_CappedCache::deleteItem | ( | const UT_CappedKey & | key | ) |
Remove an item from the cache.
|
inline |
Number of entries in the cache.
Definition at line 88 of file UT_CappedCache.h.
UT_CappedItemHandle UT_CappedCache::findItem | ( | const UT_CappedKey & | key | ) |
Find an item in the cache.
|
inline |
Return the number of entries in the list. This should match the entries in the map.
Definition at line 92 of file UT_CappedCache.h.
|
delete |
Thread safe iteration over all items in the cache. This method takes a templated class that has a () operator to process entries from the traversal. The () operator should return a bool, true if the iteration should continue, or false if the traversal can stop. For example:
deleteItem
findItem
addItem
Definition at line 154 of file UT_CappedCache.h.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |