pub struct DnsCache { /* private fields */ }Expand description
Cache for DNS records with automatic expiration.
The cache stores records along with their fetch timestamp and expires after a configurable TTL to ensure data freshness.
Implementations§
Source§impl DnsCache
impl DnsCache
Sourcepub fn new(ttl: Duration) -> Self
pub fn new(ttl: Duration) -> Self
Create a new DNS record cache.
§Arguments
ttl- How long to keep records cached before requiring a refresh
Sourcepub fn with_default_ttl() -> Self
pub fn with_default_ttl() -> Self
Create a cache with default 60-second TTL.
Sourcepub fn get(&self) -> Option<&Vec<DnsRecord>>
pub fn get(&self) -> Option<&Vec<DnsRecord>>
Get cached records if valid, otherwise returns None.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Force invalidate the cache.
Sourcepub fn remaining_ttl(&self) -> Option<Duration>
pub fn remaining_ttl(&self) -> Option<Duration>
Get remaining TTL before cache expires.
Auto Trait Implementations§
impl Freeze for DnsCache
impl RefUnwindSafe for DnsCache
impl Send for DnsCache
impl Sync for DnsCache
impl Unpin for DnsCache
impl UnsafeUnpin for DnsCache
impl UnwindSafe for DnsCache
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