libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
CacheHeader Struct Reference

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.

Detailed Description

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:

  • max_bytes: Memory budget in bytes; 0 means unlimited.
  • cur_bytes: Bytes currently held by the cached values.
  • cache: uthash root pointer; NULL when the cache is empty.
  • free_func: Optional callback to free cached values on eviction/clear.

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.

Definition at line 50 of file lru.h.

Field Documentation

◆ cache

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

◆ cur_bytes

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

◆ free_func

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

◆ max_bytes

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


The documentation for this struct was generated from the following file:
  • include/aaruformat/lru.h