pub struct RobotsCache { /* private fields */ }Expand description
Robots.txt cache
Implementations§
Source§impl RobotsCache
impl RobotsCache
Sourcepub fn with_persistence(default_ttl: Duration, persist_dir: &str) -> Self
pub fn with_persistence(default_ttl: Duration, persist_dir: &str) -> Self
Create a cache with file persistence
Sourcepub fn default_ttl(&self) -> Duration
pub fn default_ttl(&self) -> Duration
Get the default TTL
Sourcepub fn stats(&self) -> Arc<CacheStats>
pub fn stats(&self) -> Arc<CacheStats>
Get cache statistics
Sourcepub fn get(&self, key: &RobotsCacheKey) -> Option<RobotsPolicy>
pub fn get(&self, key: &RobotsCacheKey) -> Option<RobotsPolicy>
Get a policy from cache if not expired
Sourcepub fn insert(&self, key: RobotsCacheKey, policy: RobotsPolicy)
pub fn insert(&self, key: RobotsCacheKey, policy: RobotsPolicy)
Insert a policy into cache
Sourcepub fn remove(&self, key: &RobotsCacheKey) -> Option<RobotsPolicy>
pub fn remove(&self, key: &RobotsCacheKey) -> Option<RobotsPolicy>
Remove a policy from cache
Sourcepub fn evict_expired(&self) -> usize
pub fn evict_expired(&self) -> usize
Clear expired entries
Sourcepub async fn save_to_disk(&self) -> Result<usize>
pub async fn save_to_disk(&self) -> Result<usize>
Save cache to disk (if persistence enabled)
Sourcepub async fn load_from_disk(&self) -> Result<usize>
pub async fn load_from_disk(&self) -> Result<usize>
Load cache from disk (if persistence enabled)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RobotsCache
impl !RefUnwindSafe for RobotsCache
impl Send for RobotsCache
impl Sync for RobotsCache
impl Unpin for RobotsCache
impl !UnwindSafe for RobotsCache
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