DD::Image::Image_Cache Class Reference

List of all members.

Public Member Functions

void rescan_disk_cache ()
void touch_root ()
void initialize (const std::string &path, int sizegb)
bool is_active ()
 True if there has not been a failure and size is non-zero.
bool is_read ()
 True if read() has been called and thus it has loaded map.
bool is_written ()
 True if write() has been called and it created cache directories.
void remove_oldest_files (int targetblocks)
void remove_all_files ()
bool remove (const DD::Image::Hash &)
void print ()
ImageCacheReadI * open (const DD::Image::Hash &)
ImageCacheWriteI * create (const DD::Image::Hash &)
bool has_file (const DD::Image::Hash &)
std::string filename (const DD::Image::Hash &)
void add_file (const DD::Image::Hash &, off_t size)

Static Public Member Functions

static Image_CachemainCache ()
static void waitEmpty ()


Detailed Description

Manages a large LRU cache of files on disk. The files are identified by a DD::Image::Hash. The caller is responsible for the data in the files.

Member Function Documentation

Image_Cache & Image_Cache::mainCache (  )  [static]

Return the cache used by the Nuke viewer. You probably want to reuse this for any caching unless you actually have an api for the user to name and allocate space for a different cache.

void Image_Cache::initialize ( const std::string &  path,
int  sizegb 
)

Set the base directory filename and the size in gigabytes.

A blank filename or zero size will deactivate the cache so that it does not do anything (call remove_all_files() first if you really want the disk space released).

void Image_Cache::remove_oldest_files ( int  targetblocks  ) 

iterate over the age map note: 'age' isn't really age, higher numbers are newer, lower numbers are older

References DD::Image::Lock::lock(), and DD::Image::Lock::unlock().

bool Image_Cache::remove ( const DD::Image::Hash hash  ) 

Remove the file (if it exists) for the given hash. This is a good idea if you attempt to read it and then determine that the data is no good, perhaps an obsolete version of the data. Returns true if has_file() was true.

References DD::Image::Lock::lock(), and DD::Image::Lock::unlock().

ImageCacheReadI * Image_Cache::open ( const DD::Image::Hash hash  ) 

Open a file of cached data. Allocates and returns a pointer to a data structure that you must pass to the read() and close() methods. Returns NULL if the cached data does not exist.

ImageCacheWriteI * Image_Cache::create ( const DD::Image::Hash hash  ) 

Create (or replace) an existing cache file. size must be the number of bytes you will write. The file will not appear in the cache until the close() method is done.

References is_active().



©2009 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk