pub struct CacheBlockLifecycle { /* private fields */ }Expand description
Canonical logical ownership state for one backend cache session.
Backends keep concrete arrays, buffers, files, and completion objects in a
separate storage map keyed by CacheBlockId. This catalog is the sole
owner of leases, access order, protected-prefix status, and mutable tails.
Implementations§
Source§impl CacheBlockLifecycle
impl CacheBlockLifecycle
Sourcepub fn insert(
&mut self,
id: CacheBlockId,
protected_prefix: bool,
) -> Result<(), CacheLifecycleError>
pub fn insert( &mut self, id: CacheBlockId, protected_prefix: bool, ) -> Result<(), CacheLifecycleError>
Registers a newly materialized immutable block.
Sourcepub fn remove(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>
pub fn remove(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>
Removes an unleased block from logical ownership.
Sourcepub fn replace(
&mut self,
removals: &[(CacheBlockId, usize)],
replacement: Option<(CacheBlockId, bool)>,
tail_layer: usize,
tail: MutableCacheTail,
) -> Result<(), CacheLifecycleError>
pub fn replace( &mut self, removals: &[(CacheBlockId, usize)], replacement: Option<(CacheBlockId, bool)>, tail_layer: usize, tail: MutableCacheTail, ) -> Result<(), CacheLifecycleError>
Atomically replaces a set of blocks and updates one mutable tail.
The expected lease count makes a caller-owned truncation lease explicit: validation completes before any logical state is changed.
Sourcepub fn acquire(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>
pub fn acquire(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>
Acquires one exact logical lease and records demand access.
Sourcepub fn release(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>
pub fn release(&mut self, id: &CacheBlockId) -> Result<(), CacheLifecycleError>
Releases one exact logical lease.
Sourcepub fn lease_count(
&self,
id: &CacheBlockId,
) -> Result<usize, CacheLifecycleError>
pub fn lease_count( &self, id: &CacheBlockId, ) -> Result<usize, CacheLifecycleError>
Returns the exact lease count for a block.
Sourcepub fn is_leased(&self, id: &CacheBlockId) -> Result<bool, CacheLifecycleError>
pub fn is_leased(&self, id: &CacheBlockId) -> Result<bool, CacheLifecycleError>
Returns whether a block currently has any logical owner.
Sourcepub fn first_leased(&self) -> Option<&CacheBlockId>
pub fn first_leased(&self) -> Option<&CacheBlockId>
Returns the first leased block in stable identity order.
Sourcepub fn is_protected_prefix(
&self,
id: &CacheBlockId,
) -> Result<bool, CacheLifecycleError>
pub fn is_protected_prefix( &self, id: &CacheBlockId, ) -> Result<bool, CacheLifecycleError>
Returns whether the block is protected as an immutable prefix.
Sourcepub fn eviction_candidate(
&self,
candidates: impl IntoIterator<Item = CacheBlockId>,
required: Option<&CacheBlockId>,
recent_per_layer: usize,
policy: CacheEvictionPolicy,
) -> Result<Option<CacheBlockId>, CacheLifecycleError>
pub fn eviction_candidate( &self, candidates: impl IntoIterator<Item = CacheBlockId>, required: Option<&CacheBlockId>, recent_per_layer: usize, policy: CacheEvictionPolicy, ) -> Result<Option<CacheBlockId>, CacheLifecycleError>
Selects one eviction victim from backend-supplied physically eligible IDs.
Sourcepub fn recent_protection_counts(
&self,
candidates: impl IntoIterator<Item = CacheBlockId>,
recent_per_layer: usize,
) -> Result<BTreeMap<usize, u64>, CacheLifecycleError>
pub fn recent_protection_counts( &self, candidates: impl IntoIterator<Item = CacheBlockId>, recent_per_layer: usize, ) -> Result<BTreeMap<usize, u64>, CacheLifecycleError>
Counts unprotected blocks retained by a per-layer recent window.
Sourcepub fn set_tail(
&mut self,
layer: usize,
tail: MutableCacheTail,
) -> Option<MutableCacheTail>
pub fn set_tail( &mut self, layer: usize, tail: MutableCacheTail, ) -> Option<MutableCacheTail>
Replaces one layer’s mutable tail, returning the prior state for rollback.
Sourcepub fn restore_tail(&mut self, layer: usize, tail: Option<MutableCacheTail>)
pub fn restore_tail(&mut self, layer: usize, tail: Option<MutableCacheTail>)
Restores a prior tail after a failed backend admission.
Sourcepub fn tail(&self, layer: usize) -> Option<MutableCacheTail>
pub fn tail(&self, layer: usize) -> Option<MutableCacheTail>
Returns one layer’s mutable tail.
Sourcepub fn tails(&self) -> impl Iterator<Item = (usize, MutableCacheTail)> + '_
pub fn tails(&self) -> impl Iterator<Item = (usize, MutableCacheTail)> + '_
Iterates mutable tails in stable layer order.
Sourcepub fn clear(&mut self) -> Result<(), CacheLifecycleError>
pub fn clear(&mut self) -> Result<(), CacheLifecycleError>
Clears all blocks and tails only when no lease is active.