manpagez: man pages & more
man libcache(3)
Home | html | info | man
libcache(3)              BSD Library Functions Manual              libcache(3)


NAME

     libcache -- the caching framework


SYNOPSIS

     #include <cache.h>


DESCRIPTION

     The libcache framework provides a facility for creating in memory data
     caches.  Each cache is a mutable dictionary that associates values with
     their keys.  A cache limits the number of values it keeps according to
     available system memory and selects values to evict when the limit is
     exceeded.  Recently and frequently used values are less likely to be
     selected for eviction.

     Cache keys and values should be cast as pointers.  The framework provides
     a callback interface for supporting arbitrary types of keys and values
     and implements callback functions for common types.  See
     cache_callbacks(3) for more information.

     Clients retrieve a value previously added to a cache using the value's
     key.  When the client gets a value, the cache increments a reference
     count on the value.  When the client finishes with a value retrieved from
     a cache they must release the value back to the cache.  Referenced values
     are considered in use and will not be evicted.  The cache may evict
     unreferenced values (e.g. to make room for other values or reduce its
     size).

     The number of values allowed in a cache at one time is managed by the
     cache framework.  Cache size will grow when the system has available mem-
     ory and shrink under memory pressure.

     Libcache is thread-safe.  It is not safe to call back into the cache API
     from cache callback functions.


SEE ALSO

     cache_create(3), cache_set_and_retain(3)

Darwin                            May 7, 2009                           Darwin

Mac OS X 10.8 - Generated Wed Aug 29 05:25:17 CDT 2012
© manpagez.com 2000-2025
Individual documents may contain additional copyright information.