Nuke binary plugins 15.0.5
 
Loading...
Searching...
No Matches
DD::Image::Image_Cache Class Reference

#include <ImageCache.h>

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 ()
 
ImageCacheReadIopen (const DD::Image::Hash &, bool onlyInMemory=false)
 ImageCacheReadI cache files.
 
ImageCacheWriteIcreate (const DD::Image::Hash &)
 ImageCacheWriteI cache files.
 
bool has_file (const DD::Image::Hash &)
 
std::string filename (const DD::Image::Hash &)
 
void add_file (const DD::Image::Hash &, off_t size)
 
bool hasInMemory (const DD::Image::Hash &hash)
 Return true if the file for the given hash is in the in-memory ImageCache cache.
 
size_t fileSize (const DD::Image::Hash &hash)
 Get the size of the file on disk, or 0 if absent.
 

Static Public Member Functions

static Image_CachemainCache ()
 
static void setMaxMemoryCache (size_t usage)
 Set the maximum number of bytes for the in-memory ImageCache cache.
 
static size_t getMaxMemoryCache ()
 Get the maximum size (in bytes) for the in-memory ImageCache cache.
 
static void clearMemoryCache ()
 Clear the in-memory cache of ImageCache files.
 
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

◆ mainCache()

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.

Referenced by DD::Image::ViewerCache::BoxPresent(), DD::Image::ViewerCache::preload(), and DD::Image::ViewerCache::read_from_cache().

◆ initialize()

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).

◆ remove_oldest_files()

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().

◆ remove()

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(), remove(), and DD::Image::Lock::unlock().

Referenced by DD::Image::ViewerCache::read_from_cache(), and remove().

◆ open()

ImageCacheReadI * Image_Cache::open ( const DD::Image::Hash hash,
bool  onlyInMemory = false 
)

ImageCacheReadI cache files.

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.

read it all in at once, and put it into a memory buffer. put this into a Write, and then add that to the cache and arrange a WriteRead to point at that.

Referenced by DD::Image::ViewerCache::BoxPresent(), and DD::Image::ViewerCache::read_from_cache().

◆ create()

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

ImageCacheWriteI cache files.

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().



©2024 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com