pub struct TileCache { /* private fields */ }Expand description
A byte-budgeted LRU cache of graph intermediates.
Shared across scheduler threads; all methods take &self.
Implementations§
Source§impl TileCache
impl TileCache
Sourcepub const DEFAULT_BUDGET: usize
pub const DEFAULT_BUDGET: usize
The default retention budget: 64 MiB.
Sourcepub fn new(budget: usize) -> Self
pub fn new(budget: usize) -> Self
A cache retaining at most budget bytes of tiles.
A budget of zero disables retention entirely: every lookup misses, which is a useful way to test that a pipeline is correct without any caching at all.
Sourcepub fn get(&self, key: &TileKey) -> Option<Arc<TileBuf>>
pub fn get(&self, key: &TileKey) -> Option<Arc<TileBuf>>
Look up a tile, marking it most-recently-used on a hit.
The returned Arc keeps the tile alive regardless of later eviction.
Sourcepub fn insert(&self, key: TileKey, tile: Arc<TileBuf>) -> Arc<TileBuf> ⓘ
pub fn insert(&self, key: TileKey, tile: Arc<TileBuf>) -> Arc<TileBuf> ⓘ
Offer a tile to the cache, evicting as needed to stay within budget.
Returns the tile, so a caller can insert and use it in one step. A tile larger than the entire budget is returned without being retained rather than evicting everything to make room for something that cannot fit.
Sourcepub fn bytes_used(&self) -> usize
pub fn bytes_used(&self) -> usize
Bytes currently retained.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
A snapshot of the cache counters.