pub struct FileCache { /* private fields */ }Expand description
Global LRU cache for parquet file contents, shared across all readers and queries.
Memory budget is based on file size. Uses moka’s try_get_with to prevent
thundering herd - concurrent requests for the same uncached file will coalesce
into a single load operation.
Implementations§
Source§impl FileCache
impl FileCache
Sourcepub fn new(max_capacity_bytes: u64, max_file_size_bytes: u64) -> FileCache
pub fn new(max_capacity_bytes: u64, max_file_size_bytes: u64) -> FileCache
Creates a new file cache with the specified memory budget and max file size.
Sourcepub fn should_cache(&self, file_size: u64) -> bool
pub fn should_cache(&self, file_size: u64) -> bool
Check if a file should be cached based on its size
Sourcepub async fn get_or_load<F, Fut, E>(
&self,
file_path: &str,
file_size: u64,
loader: F,
) -> Result<Bytes, Error>
pub async fn get_or_load<F, Fut, E>( &self, file_path: &str, file_size: u64, loader: F, ) -> Result<Bytes, Error>
Gets file contents, loading from the provided async function on cache miss.
Uses moka’s try_get_with to coalesce concurrent requests - if multiple
callers request the same uncached file simultaneously, only one will
execute the loader while others wait for the result.
Returns an error if file_size >= 4GB (moka weigher uses u32).
Sourcepub async fn run_pending_tasks(&self)
pub async fn run_pending_tasks(&self)
Runs pending cache maintenance tasks.
This should be called to ensure cache statistics are up-to-date, particularly useful in test scenarios.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileCache
impl !RefUnwindSafe for FileCache
impl Send for FileCache
impl Sync for FileCache
impl Unpin for FileCache
impl !UnwindSafe for FileCache
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].