Skip to main content


ec_cache_create2 — Create a cache with max_elts


#include "ec_cache.h"

| ec_cache_t * **ec_cache_create2** ( | max_elts, |   | |   | max_lifetime, |   | |   | dtor, |   | |   | name); |   |

unsigned int <var class="pdparam">max_elts</var>; unsigned int <var class="pdparam">max_lifetime</var>; ec_cache_elt_dtor_func <var class="pdparam">dtor</var>; const char * <var class="pdparam">name</var>;


Create a cache with max_elts.



The maximum number of elements that can be kept in the cache. If that number is exceeded, then the least recently used (LRU) element will be removed from the cache.


Specifies a time-to-live (TTL) in seconds for the cache element. If max_lifetime is not given the value EC_CACHE_LIFETIME_INFINITE, then it specifies a time-to-live in seconds after which the entry will be removed from the cache. Otherwise, the TTL will be ignored. If using the cache in per-item-ttl mode, then max_lifetime is actually a number of additional seconds beyond the ttl for which an element will not be removed.


Specifies a function that will be called when the refcount of an item becomes zero. The following typedef applies to this data type:

typedef void (*ec_cache_elt_dtor_func)(void *value); .


Specify a cache name for the cache. If name is not NULL, then the name can be used to globally identify the cache for introspection purposes.

Return Values

Returns the address of an ec_cache_t type. The following typedef applies to this data type:

typedef struct ec_cache_head ec_cache_t;.


While it is legal to call this function in any thread, it should only be called in the Scheduler thread.

See Also

Was this page helpful?