clrucache · Section 3
clrucache_size
NAME
clrucache_size - return the number of live entries in the cache
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/clrucache.h> size_t clrucache_size(ccache cache);
DESCRIPTION
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.
PARAMETERS
cache Cache handle.
RETURN VALUE
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.
NOTES
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).