Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cache_callbacks(3) [osx man page]

cache_callbacks(3)					   BSD Library Functions Manual 					cache_callbacks(3)

NAME
cache_callbacks -- Pre-defined cache callbacks used to configure a cache SYNOPSIS
#include <cache.h> #include <cache_callbacks.h> uintptr_t cache_key_hash_cb_cstring(void *key, void *unused); uintptr_t cache_key_hash_cb_integer(void *key, void *unused); bool cache_key_is_equal_cb_cstring(void *key1, void *key2, void *unused); bool cache_key_is_equal_cb_integer(void *key1, void *key2, void *unused); void cache_release_cb_free(void *key_or_value, void *unused); void cache_value_make_purgeable_cb(void *value, void *unused); bool cache_value_make_nonpurgeable_cb(void *value, void *unused); uintptr_t cache_hash_byte_string(const char *data, size_t bytes); DESCRIPTION
These functions are intended to be used as callbacks to configure how a cache functions. They should be set in the cache_attributes_t passed into cache_create. They support common key types and offer support for using purgeable memory to allocate cache values. cache_key_hash_cb_cstring() A key_hash_cb() function for NULL-terminated cstring keys. cache_key_hash_cb_integer() A key_hash_cb() function for integer keys. cache_key_is_equal_cb_cstring() A key_is_equal_cb() function for cstring keys. cache_key_is_equal_cb_integer() A key_is_equal_cb() function for integer keys. cache_release_cb_free() Can be used for key_release_cb() or value_release_cb() for keys/values allocated from malloc and family. cache_value_make_purgeable_cb() Can be used for value_make_purgeable() with values allocated from the purgeable malloc zone (see malloc/mal- loc.h). Calls malloc_make_purgeable() on value when it is unreferenced in order to reduce paging under memory pressure. value_make_purgeable() with values allocated from the purgeable malloc zone (see malloc/malloc.h). Calls malloc_make_purgeable() on value when it is unreferenced in order to reduce paging under memory pressure. cache_hash_byte_string() Calculates a hash from a bytes string data of length bytes. SEE ALSO
libcache(3) cache_create(3) Darwin May 7, 2009 Darwin

Check Out this Related Man Page

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 memory 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
Man Page