pub struct TileCache {
pub max_entries: usize,
pub max_bytes: u64,
pub current_bytes: u64,
pub hit_count: u64,
pub miss_count: u64,
pub eviction_count: u64,
/* private fields */
}Expand description
LRU tile cache with entry-count and byte-budget eviction.
Entries at the back of access_order are most recently used;
the front is evicted first.
Fields§
§max_entries: usizeMaximum number of entries before LRU eviction.
max_bytes: u64Maximum total bytes before LRU eviction.
current_bytes: u64Current total bytes of cached tile data.
hit_count: u64Cumulative cache hits.
miss_count: u64Cumulative cache misses.
eviction_count: u64Cumulative evictions.
Implementations§
Source§impl TileCache
impl TileCache
Sourcepub fn new(max_entries: usize, max_bytes: u64) -> Self
pub fn new(max_entries: usize, max_bytes: u64) -> Self
Creates a new TileCache with the given capacity limits.
Sourcepub fn get(&mut self, key: &TileKey, now: u64) -> Option<&CachedTile>
pub fn get(&mut self, key: &TileKey, now: u64) -> Option<&CachedTile>
Looks up key in the cache. On a hit the access metadata is updated
and the key is promoted to the back of the LRU queue.
Sourcepub fn insert(&mut self, tile: CachedTile)
pub fn insert(&mut self, tile: CachedTile)
Inserts tile into the cache, evicting LRU entries as needed.
Sourcepub fn invalidate(&mut self, key: &TileKey) -> bool
pub fn invalidate(&mut self, key: &TileKey) -> bool
Removes key from the cache. Returns true if the entry existed.
Sourcepub fn invalidate_layer(&mut self, layer: &str) -> u64
pub fn invalidate_layer(&mut self, layer: &str) -> u64
Removes all tiles belonging to layer. Returns the number of entries removed.
Sourcepub fn invalidate_zoom_range(&mut self, min_z: u8, max_z: u8) -> u64
pub fn invalidate_zoom_range(&mut self, min_z: u8, max_z: u8) -> u64
Removes all tiles whose zoom level falls within [min_z, max_z].
Returns the number of entries removed.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Returns a snapshot of current cache statistics.
Auto Trait Implementations§
impl Freeze for TileCache
impl RefUnwindSafe for TileCache
impl Send for TileCache
impl Sync for TileCache
impl Unpin for TileCache
impl UnsafeUnpin for TileCache
impl UnwindSafe for TileCache
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> 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