C Collections

clrucache · Section 3

ccache_init

ccache_init - initialise a previously declared LRU cache variable

C Collections (libccollections, -lccollections)

#include <ccollections/clrucache.h>
 
ccache_init(name, capacity, getter, setter, evict_cb);

Calls clrucache_create_full() and assigns the result to name, with the
key type and the value type taken from the companion variables that
ccache_declare() created. It calls ccol__fatal_err() when the creation
fails.

name       Cache variable. Declare it with ccache_declare or
           ccache_declare_scoped first
capacity   The total number of live entries; see
           clrucache_create_full(3). It must be greater than 0
getter     Remote getter callback, or NULL
setter     Remote setter callback, or NULL
evict_cb   Eviction callback, or NULL

The macro calls ccol__fatal_err() when an allocation fails, so call
clrucache_create_full() directly when you must handle an error
yourself.

ccache_declare(cache, int, double);
ccache_init(cache, 64, NULL, NULL, NULL);
ccache_destroy(cache);

ccache_declare(3), ccache_construct(3), clrucache_create_full(3)