|
libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
|
Cache top-level descriptor encapsulating the hash table root and capacity limit. More...
#include <aaruformat/lru.h>
Data Fields | |
| uint64_t | max_bytes |
| Memory budget in bytes for the cached values. 0 means unlimited. | |
| uint64_t | cur_bytes |
| Bytes currently held by the cached values. | |
| struct CacheEntry * | cache |
| Hash root (uthash). NULL when empty. | |
| void(*) | free_func (void *) |
| Optional callback to free cached values. NULL if not needed. | |
Cache top-level descriptor encapsulating the hash table root and capacity limit.
The cache is bounded by the total number of bytes held by its values, not by the number of entries: the caches in this library store values of wildly different sizes (a block header is a few dozen bytes, a decompressed data block is megabytes), so an entry-count limit cannot express a memory budget. On insert, the least recently used entries are evicted until the cache is back under max_bytes.
Fields:
The entry just inserted is never evicted, so a caller may keep using the pointer it handed over for the remainder of the call even if the value is larger than max_bytes.
| struct CacheEntry* CacheHeader::cache |
Hash root (uthash). NULL when empty.
Definition at line 54 of file lru.h.
Referenced by aaruf_create(), aaruf_open(), add_to_cache_uint64(), drop_entry(), find_in_cache_uint64(), and free_cache().
| uint64_t CacheHeader::cur_bytes |
Bytes currently held by the cached values.
Definition at line 53 of file lru.h.
Referenced by aaruf_create(), aaruf_open(), add_to_cache_uint64(), drop_entry(), and free_cache().
| void(*) CacheHeader::free_func(void *) |
Optional callback to free cached values. NULL if not needed.
Definition at line 55 of file lru.h.
Referenced by aaruf_create(), aaruf_open(), add_to_cache_uint64(), and drop_entry().
| uint64_t CacheHeader::max_bytes |
Memory budget in bytes for the cached values. 0 means unlimited.
Definition at line 52 of file lru.h.
Referenced by aaruf_create(), aaruf_open(), and add_to_cache_uint64().