C Collections

clrucache · Section 3

clrucache_size

clrucache_size - return the number of live entries in the cache

C Collections (libccollections, -lccollections)

#include <ccollections/clrucache.h>
 
size_t clrucache_size(ccache cache);

Returns the number of live entries in the cache at the moment. A live
entry is one that is fully initialised and that no eviction has
removed, so a placeholder entry created by a fetch or a set in
progress is not counted.

cache  Cache handle.

The number of live entries. It is 0 when cache is CCACHE_NULL,
and 0 when cache is a stale handle that a call already destroyed.

cache is an opaque VALUE handle, which the library resolves through a
slot table of its own before it touches the cache object behind it. A
stale handle is an ordinary error here and not a fatal one; only
ccache_destroy() treats a stale handle as fatal.
The function adds up the sizes of the cache's segments, taking each
segment's own lock in turn. So the result is a snapshot and not a
value at one instant: A segment can gain or lose an entry after it has
been counted, and the total describes no single moment.
The complexity is O(number of segments), a small fixed bound, not
O(entries).

clrucache_capacity(3), clrucache_create_full(3)