pub struct CellCache { /* private fields */ }Expand description
Local cell cache with LRU eviction policy.
The cache stores recently accessed cells from object storage in the local filesystem. When the cache exceeds its size limit, the least recently accessed entries are evicted.
§Thread Safety
The cache is designed for concurrent access from multiple bees. All
operations use interior mutability via RwLock and atomic operations.
Implementations§
Source§impl CellCache
impl CellCache
Sourcepub async fn new(
cache_dir: PathBuf,
max_size: u64,
storage: Arc<dyn StorageBackend>,
) -> Result<Self>
pub async fn new( cache_dir: PathBuf, max_size: u64, storage: Arc<dyn StorageBackend>, ) -> Result<Self>
Create a new CellCache with the specified directory and size limit.
§Arguments
cache_dir— Directory where cached cells will be stored.max_size— Maximum total size of cached files in bytes.storage— Storage backend for fetching cells on cache miss.
§Errors
Returns an error if the cache directory cannot be created.
Sourcepub async fn get(&self, storage_key: &str) -> Result<PathBuf>
pub async fn get(&self, storage_key: &str) -> Result<PathBuf>
Get a cell from the cache or fetch it from storage on cache miss.
§Arguments
storage_key— The storage key for the cell (e.g., “cells/frame_id/cell_abc.parquet”).
§Returns
Returns the local filesystem path to the cached cell.
§Behavior
- Cache hit: Updates last accessed time and returns the local path.
- Cache miss: Fetches the cell from storage, adds it to the cache, and returns the path.
- Automatically evicts LRU entries if the cache exceeds its size limit.
Sourcepub async fn list_cached_cells(&self) -> HashMap<String, u64>
pub async fn list_cached_cells(&self) -> HashMap<String, u64>
Get a list of all cached cells for heartbeat reporting.
Returns a map of storage keys to their sizes in bytes.
Auto Trait Implementations§
impl Freeze for CellCache
impl !RefUnwindSafe for CellCache
impl Send for CellCache
impl Sync for CellCache
impl Unpin for CellCache
impl UnsafeUnpin for CellCache
impl !UnwindSafe for CellCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more