Skip to main content

Name

ec_cache_create — Create a cache with max_elts

Synopsis

#include "ec_cache.h"

| ec_cache_t * **ec_cache_create** ( | max_elts, |   | |   | max_lifetime, |   | |   | dtor); |   |

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>;

Description

Create a cache with max_elts.

Note

This is equivalent to calling ec_cache_create2 with a NULL name parameter.

Parameters

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.

max_lifetime

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. 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.

dtor

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); .

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;.

Threading

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?