pub struct MapCache { /* private fields */ }Expand description
Map cache backed by the filesystem with LRU eviction.
Implementations§
Source§impl MapCache
impl MapCache
Sourcepub fn new(cache_dir: PathBuf, default_ttl: Duration) -> Result<Self>
pub fn new(cache_dir: PathBuf, default_ttl: Duration) -> Result<Self>
Create a new map cache in the given directory.
On creation, scans the cache directory for existing .ctx files and
rebuilds the in-memory index so that previously cached maps are
immediately available for lookup.
Sourcepub fn default_cache() -> Result<Self>
pub fn default_cache() -> Result<Self>
Create a cache with default settings (~/.cortex/maps/, 1 hour TTL).
Sourcepub fn get(&mut self, domain: &str) -> Option<&Path>
pub fn get(&mut self, domain: &str) -> Option<&Path>
Get a cached map for the domain if it exists and is fresh.
Sourcepub fn put(&mut self, domain: &str, data: &[u8]) -> Result<PathBuf>
pub fn put(&mut self, domain: &str, data: &[u8]) -> Result<PathBuf>
Cache a serialized map for the domain.
If the cache is full, the least-recently-used entry is evicted first.
Sourcepub fn cache_map(&mut self, domain: &str, map: &SiteMap) -> Result<PathBuf>
pub fn cache_map(&mut self, domain: &str, map: &SiteMap) -> Result<PathBuf>
Cache a SiteMap by serializing it.
Sourcepub fn load_map(&mut self, domain: &str) -> Result<Option<SiteMap>>
pub fn load_map(&mut self, domain: &str) -> Result<Option<SiteMap>>
Load a cached SiteMap for the domain.
Sourcepub fn load_all_maps(&mut self) -> Result<HashMap<String, SiteMap>>
pub fn load_all_maps(&mut self) -> Result<HashMap<String, SiteMap>>
Load all cached (non-expired) SiteMaps, returning a domain → SiteMap map.
Sourcepub fn invalidate(&mut self, domain: &str)
pub fn invalidate(&mut self, domain: &str)
Invalidate (remove) a cached map.
Sourcepub fn cleanup_expired(&mut self)
pub fn cleanup_expired(&mut self)
Remove all expired entries.
Auto Trait Implementations§
impl Freeze for MapCache
impl RefUnwindSafe for MapCache
impl Send for MapCache
impl Sync for MapCache
impl Unpin for MapCache
impl UnsafeUnpin for MapCache
impl UnwindSafe for MapCache
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