Memory and concurrency
Reuse aligned buffers
Direct I/O needs 4-KiB page-aligned buffers. Feuer keeps a BufferPool inside
the memory cache with fixed size buckets from 4 KiB to 64 MiB (plus a bucket
for larger buffers) so reads reuse existing allocations instead of allocating
and faulting fresh pages.
Idle buffers count against the same byte budget as cached objects. When the cache needs room for new entries, it frees idle buffers alongside evicting entries.
You can also grab an AlignedBuffer directly with cache.allocate_buffer(),
write your download or computed bytes into it, and pass it straight into Feuer
without an extra copy.
Sharded memory storage
The memory cache splits its budget across shards picked by key hash. Each shard
has its own lock and evicts locally. By default, Feuer creates
max(1, memory_capacity / 8 GiB) shards. Override it with
.memory_shard_count(n) or FEUER_MEMORY_SHARD_COUNT.
Lookups return a Bytes handle pointing at the cached buffer without copying
the payload or holding the shard lock afterward.
Share concurrent work
If multiple tasks ask for the same key at the same time, Feuer runs one disk read or source fetch and shares the result with all of them.
Caller A ─┐
Caller B ─┼─ same object ── one disk read or source fetch
Caller C ─┘ │
shared result
For get_or_fetch, callers share work when both the key and callback error
type match. Cancelling one caller leaves the fetch running for the others. Only
dropping the last waiter cancels it. Callbacks for the same key need to return
interchangeable bytes, since whichever caller starts the fetch supplies the
result for everyone waiting.