BRL-CAD
cache.h File Reference
#include "common.h"
#include "bu/defines.h"
Include dependency graph for cache.h:

Go to the source code of this file.

Data Structures

struct  bu_cache
 

Functions

struct bu_cachebu_cache_open (const char *cache_db, int create)
 
void bu_cache_close (struct bu_cache *c)
 
void bu_cache_erase (const char *cache_db)
 
size_t bu_cache_get (void **data, const char *key, struct bu_cache *c)
 
void bu_cache_get_done (const char *key, struct bu_cache *c)
 
size_t bu_cache_write (void **data, const char *key, struct bu_cache *c)
 
void bu_cache_clear (const char *key, struct bu_cache *c)
 

Detailed Description

Routines for managing and accessing a key/value data store.

Definition in file cache.h.

Function Documentation

◆ bu_cache_open()

struct bu_cache* bu_cache_open ( const char *  cache_db,
int  create 
)

Opens the specified cache database from the BRL-CAD BU_DIR_CACHE folder. The cache_db string may contain a hierarchical path, but note that all paths will be interpreted as relative to the BU_DIR_CACHE location - no absolute paths can be specified.

If the create flag is non-zero, bu_cache_open will create the specified cache_db if it does not already exist.

returns the bu_cache structure on success, NULL on failure.

◆ bu_cache_close()

void bu_cache_close ( struct bu_cache c)

Closes the bu_cache and frees all associated memory.

◆ bu_cache_erase()

void bu_cache_erase ( const char *  cache_db)

Erase the specified cache from disk. Any open instances of the cache should be closed before calling this function.

◆ bu_cache_get()

size_t bu_cache_get ( void **  data,
const char *  key,
struct bu_cache c 
)

Retrieve data (read-only) from the cache using the specified key. User should call bu_cache_get_done once their use of data is complete.

Returns the size of the retrieved data.

◆ bu_cache_get_done()

void bu_cache_get_done ( const char *  key,
struct bu_cache c 
)

Data retrieved using bu_cache_get is temporary - once the user is done either reading it or copying it, libbu needs to be told that the usage of the returned data is complete.

◆ bu_cache_write()

size_t bu_cache_write ( void **  data,
const char *  key,
struct bu_cache c 
)

Assign data to the cache using the specified key

◆ bu_cache_clear()

void bu_cache_clear ( const char *  key,
struct bu_cache c 
)

Clear data associated with the specified key from the cache