HDK
|
A disk cache to store expensive data on a local disk. More...
#include <UT_LocalDiskCache.h>
Public Member Functions | |
UT_LocalDiskCache (const char *cache_name, int64 max_item_size, int64 max_item_count) | |
~UT_LocalDiskCache () | |
void | clearCache (bool reset_file=true) |
bool | extractFromCache (const UT_LocalDiskCacheKey &key, void *buffer, int64 &buffer_size, bool remove_from_cache=true) |
void | storeInCache (const UT_LocalDiskCacheKey &key, const void *buffer, int64 buffer_size) |
Store in the cache. More... | |
int64 | getMemoryUsed () const |
Get memory used. More... | |
int64 | getFileSize () const |
Get the file size. More... | |
template<typename T > | |
void | traverseCache (T &task) |
Traverse the cache. More... | |
const UT_CappedCache & | getCache () const |
Const access to the cache. More... | |
A disk cache to store expensive data on a local disk.
In some cases, accessing data can be expensive:
This cache makes a reasonable secondary cache.
Definition at line 47 of file UT_LocalDiskCache.h.
UT_LocalDiskCache::UT_LocalDiskCache | ( | const char * | cache_name, |
int64 | max_item_size, | ||
int64 | max_item_count | ||
) |
The cache is used to store data in a temporary disk file max_item_size
is the maximum size for each item put into the cache max_item_count
is the maximum number of items to be stored in the cache It's fairly obvious that the maximum size for the disk file will be max_item_size*max_item_count
.
UT_LocalDiskCache::~UT_LocalDiskCache | ( | ) |
void UT_LocalDiskCache::clearCache | ( | bool | reset_file = true | ) |
Clear entire disk cache. This is not thread safe and should only be called when the cache isn't under contention.
bool UT_LocalDiskCache::extractFromCache | ( | const UT_LocalDiskCacheKey & | key, |
void * | buffer, | ||
int64 & | buffer_size, | ||
bool | remove_from_cache = true |
||
) |
Extract from the disk cache. Once extracted, the item will no longer exist in the cache.
The remove_from_cache
flag determines whether the object will be removed from the disk cache after extraction. Since this cache is usually used as a secondary cache, it's usually the primary cache which extracts the data from the disk cache (keeping the object in the primary cache after).
|
inline |
Const access to the cache.
Definition at line 97 of file UT_LocalDiskCache.h.
|
inline |
Get the file size.
Definition at line 88 of file UT_LocalDiskCache.h.
int64 UT_LocalDiskCache::getMemoryUsed | ( | ) | const |
Get memory used.
void UT_LocalDiskCache::storeInCache | ( | const UT_LocalDiskCacheKey & | key, |
const void * | buffer, | ||
int64 | buffer_size | ||
) |
Store in the cache.
Traverse the cache.
Definition at line 91 of file UT_LocalDiskCache.h.