HDK
|
#include <FS_DiskCache.h>
Classes | |
class | Accessor |
class | Key |
class | Stats |
Statistics for the cache. More... | |
Public Types | |
enum | InsertStatus { INSERT_CREATE, INSERT_EXIST, INSERT_ERROR } |
Possible return values for the insert() function. More... | |
Public Member Functions | |
FS_DiskCache (const UT_StringHolder &path=UT_StringHolder(), exint default_size_in_bytes=0) | |
~FS_DiskCache () | |
bool | isValid () const |
Check to see if the cache is valid. More... | |
bool | initialize (const UT_StringHolder &path) |
bool | setMaxSize (int64 size_in_bytes=256 *1024 *1024) |
Set the maximum data size of the cache. More... | |
bool | setMaxLogSize (int64 size_in_bytes=1024 *1024) |
Set the maximum log size of the cache. More... | |
int64 | maxSize () const |
Return the maximum size of the cache. More... | |
int64 | maxLogSize () const |
Return the maximum size of the log file. More... | |
bool | stats (Stats &stats) const |
Get statistics for the cache. More... | |
const UT_StringHolder & | location () const |
Return the location of the path. More... | |
bool | recompute () |
Reset the cache. More... | |
bool | clearCache () const |
Clear the cache contents. More... | |
bool | clobberCache () |
Reset the cache entirely. More... | |
InsertStatus | insert (Accessor &access, const Key &key) |
bool | find (Accessor &access, const Key &key) const |
bool | purge (bool force=false) const |
Purge items from a cache to meet size requirements using LRU. More... | |
void | dump () const |
Dump debug information about the cache. More... | |
bool | dump (UT_JSONWriter &w) const |
void | printLog (const char *fmt,...) const SYS_PRINTF_CHECK_ATTRIBUTE(2 |
template<typename... Args> | |
void void | log (const char *fmt, const Args &...args) const |
Friends | |
class | Accessor |
A disk cache can store data on disk. The cache is designed to be thread-safe, even across multiple processes.
This class is intended to be a singleton.
Definition at line 27 of file FS_DiskCache.h.
Possible return values for the insert()
function.
Enumerator | |
---|---|
INSERT_CREATE |
New item, accessor has write-only file. |
INSERT_EXIST |
Existing item, accessor has read-only file. |
INSERT_ERROR |
Unknown error, accessor will be invalid. |
Definition at line 259 of file FS_DiskCache.h.
FS_DiskCache::FS_DiskCache | ( | const UT_StringHolder & | path = UT_StringHolder() , |
exint | default_size_in_bytes = 0 |
||
) |
FS_DiskCache::~FS_DiskCache | ( | ) |
bool FS_DiskCache::clearCache | ( | ) | const |
Clear the cache contents.
bool FS_DiskCache::clobberCache | ( | ) |
Reset the cache entirely.
void FS_DiskCache::dump | ( | ) | const |
Dump debug information about the cache.
bool FS_DiskCache::dump | ( | UT_JSONWriter & | w | ) | const |
Find an item in the disk cache. If found, the Accessor will have read-only access to the item. The item cannot be deleted from the cache while it's referenced.
bool FS_DiskCache::initialize | ( | const UT_StringHolder & | path | ) |
Initialize the disk cache from a given path. If the path doesn't exist, the cache will be created.
InsertStatus FS_DiskCache::insert | ( | Accessor & | access, |
const Key & | key | ||
) |
|
inline |
Check to see if the cache is valid.
Definition at line 225 of file FS_DiskCache.h.
|
inline |
Return the location of the path.
Definition at line 247 of file FS_DiskCache.h.
|
inline |
Definition at line 288 of file FS_DiskCache.h.
|
inline |
Return the maximum size of the log file.
Definition at line 241 of file FS_DiskCache.h.
|
inline |
Return the maximum size of the cache.
Definition at line 238 of file FS_DiskCache.h.
void FS_DiskCache::printLog | ( | const char * | fmt, |
... | |||
) | const |
bool FS_DiskCache::purge | ( | bool | force = false | ) | const |
Purge items from a cache to meet size requirements using LRU.
bool FS_DiskCache::recompute | ( | ) |
Reset the cache.
bool FS_DiskCache::setMaxLogSize | ( | int64 | size_in_bytes = 1024 *1024 | ) |
Set the maximum log size of the cache.
bool FS_DiskCache::setMaxSize | ( | int64 | size_in_bytes = 256 *1024 *1024 | ) |
Set the maximum data size of the cache.
bool FS_DiskCache::stats | ( | Stats & | stats | ) | const |
Get statistics for the cache.
Definition at line 312 of file FS_DiskCache.h.