95typedef enum : uint8_t {
389 uint32_t* out_misses,
390 uint32_t* out_evictions);
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_err_t ra8_keycache_get(ra8_keycache_t *kc, const void *key, ra8_keycache_view_t *out_view)
Get (and pin) the cell for key, rendering it on a miss.
ra8_err_t ra8_keycache_stats(const ra8_keycache_t *kc, uint32_t *out_hits, uint32_t *out_misses, uint32_t *out_evictions)
Report the cache hit / miss / eviction counters.
uint32_t(* ra8_keycache_hash_fn)(const void *key, uint32_t key_bytes, void *ctx)
Hash a key blob to a raw 32-bit value (the engine folds to a bucket).
ra8_err_t(* ra8_keycache_render_fn)(void *ctx, const void *key, uint8_t *cell, uint32_t cell_bytes, void *user)
Fill a cell with the rendered bytes for key (render-on-miss seam).
ra8_err_t ra8_keycache_init(ra8_keycache_t *kc, const ra8_keycache_cfg_t *cfg)
Initialise a cache engine over caller-supplied storage.
ra8_err_t ra8_keycache_put(ra8_keycache_t *kc, const uint8_t *data)
Release one pin on a cell previously returned by ra8_keycache_get.
ra8_keycache_evict_t
Eviction policy selected in ra8_keycache_cfg_t::evict.
@ k_ra8_keycache_evict_lru
Single-list LRU (the default when 0).
@ k_ra8_keycache_evict_slru
Segmented LRU / 2Q (scan-resistant).
ra8_err_t ra8_keycache_prefetch(ra8_keycache_t *kc, const void *key)
Warm the cell for key into the cache without holding a pin.
Per-cell link metadata (one caller-owned array entry per cell).
int32_t next
Recency link toward LRU within the segment, or -1.
uint16_t pin_count
Outstanding pins (0 => evictable).
int32_t prev
Recency link toward MRU within the segment, or -1.
uint8_t valid
1 => this cell holds an entry.
uint8_t seg
SLRU segment tag (probationary / protected).
int32_t hash_next
Hash bucket chain link, or -1.
Caller-supplied storage + policy + renderer for ra8_keycache_init.
void * hash_ctx
Opaque context passed to hash.
uint32_t bucket_count
Number of hash buckets (>= 1).
uint32_t user_bytes
Bytes per user descriptor (may be 0).
uint8_t * cell_mem
cell_count * cell_bytes of cell storage.
uint8_t protected_pct
SLRU protected share 1..100; 0 => 75%.
uint32_t cell_bytes
Bytes per cell (the rendered payload).
uint8_t * key_mem
cell_count * key_bytes of key storage.
int32_t * buckets
bucket_count hash-bucket heads.
ra8_keycache_evict_t evict
Eviction policy (0 => LRU; SLRU opt-in).
uint32_t key_bytes
Bytes per key (>= 1).
ra8_keycache_cell_t * meta
cell_count link-metadata entries.
uint32_t cell_count
Number of cells.
void * render_ctx
Opaque context passed to render.
ra8_keycache_render_fn render
Render-on-miss callback.
uint8_t * user_mem
cell_count * user_bytes, or NULL if none.
ra8_keycache_hash_fn hash
Key hash; NULL selects built-in FNV-1a.
Cache engine state (caller-owned; treat as private).
uint32_t protected_count
Cells in the protected segment.
int32_t pt_tail
Protected LRU cell, or -1 (SLRU only).
uint32_t protected_cap
Protected-segment capacity (0 = LRU).
int32_t pt_head
Protected MRU cell, or -1 (SLRU only).
uint32_t hits
Get hits so far.
uint32_t misses
Get misses so far.
ra8_keycache_cfg_t cfg
Configuration (copied at init).
uint32_t evictions
Entries evicted so far.
int32_t pb_tail
Probationary LRU cell, or -1.
int32_t pb_head
Probationary MRU cell, or -1.
A pinned view of a cached cell returned by ra8_keycache_get.
uint8_t * data
Cell payload (cell_bytes wide).
void * user
Per-cell user descriptor, or NULL.