pub struct BlockCache { /* private fields */ }Expand description
Shared, byte-bounded cache of decoded TIFF blocks.
BlockCache is cheaply cloneable; clones share the same underlying cache
(the inner moka::future::Cache is Arc-backed) and the same stats
counters.
Implementations§
Source§impl BlockCache
impl BlockCache
Sourcepub fn new(cfg: CacheConfig) -> Self
pub fn new(cfg: CacheConfig) -> Self
Build a new cache honoring cfg.
Sourcepub fn stats(&self) -> BlockCacheStats
pub fn stats(&self) -> BlockCacheStats
Snapshot the cache’s activity counters and current occupancy.
Cheap and non-blocking; intended to be polled periodically by a metrics
exporter. entries/resident_bytes come from moka and are eventually
consistent.
Sourcepub async fn try_get_with(
&self,
key: BlockKey,
init: impl Future<Output = Result<DecodedBlock, AgError>>,
) -> Result<Arc<DecodedBlock>, AgError>
pub async fn try_get_with( &self, key: BlockKey, init: impl Future<Output = Result<DecodedBlock, AgError>>, ) -> Result<Arc<DecodedBlock>, AgError>
Return the cached block for key, calling init exactly once when
there is no live entry (concurrent requests are coalesced).
init should produce a raw DecodedBlock; this method wraps it in
Arc before insertion so that all callers receive Arc-equal
pointers on a cache hit.
Sourcepub async fn get(&self, key: &BlockKey) -> Option<Arc<DecodedBlock>>
pub async fn get(&self, key: &BlockKey) -> Option<Arc<DecodedBlock>>
Probe the cache without populating it. Records a hit or miss.
Sourcepub async fn sync_count(&self) -> u64
pub async fn sync_count(&self) -> u64
Flush pending internal tasks and return the number of live entries.
moka’s entry_count is eventually consistent; calling
run_pending_tasks first makes it deterministic in unit tests.
Intended for tests and diagnostics only; do not call on hot paths.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BlockCache
impl !UnwindSafe for BlockCache
impl Freeze for BlockCache
impl Send for BlockCache
impl Sync for BlockCache
impl Unpin for BlockCache
impl UnsafeUnpin for BlockCache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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