HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FS_DiskCache Class Reference

#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_StringHolderlocation () 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
 

Detailed Description

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.

Member Enumeration Documentation

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.

Constructor & Destructor Documentation

FS_DiskCache::FS_DiskCache ( const UT_StringHolder path = UT_StringHolder(),
exint  default_size_in_bytes = 0 
)
FS_DiskCache::~FS_DiskCache ( )

Member Function Documentation

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
bool FS_DiskCache::find ( Accessor access,
const Key key 
) 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 
)

Similar to UT_ConcurrentHash, this method will try to insert an item into the cache. If the item exists in the cache, insert() will return false and the Accessor will have read-only access to the item.

bool FS_DiskCache::isValid ( ) const
inline

Check to see if the cache is valid.

Definition at line 225 of file FS_DiskCache.h.

const UT_StringHolder& FS_DiskCache::location ( ) const
inline

Return the location of the path.

Definition at line 247 of file FS_DiskCache.h.

template<typename... Args>
void void FS_DiskCache::log ( const char *  fmt,
const Args &...  args 
) const
inline

Definition at line 288 of file FS_DiskCache.h.

int64 FS_DiskCache::maxLogSize ( ) const
inline

Return the maximum size of the log file.

Definition at line 241 of file FS_DiskCache.h.

int64 FS_DiskCache::maxSize ( ) const
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.

Friends And Related Function Documentation

friend class Accessor
friend

Definition at line 312 of file FS_DiskCache.h.


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