pub struct DnsCache { /* private fields */ }Expand description
An in-memory DNS cache with TTL-based expiry.
Implementations§
Source§impl DnsCache
impl DnsCache
Sourcepub const fn set_ttl(&mut self, ttl: Duration)
pub const fn set_ttl(&mut self, ttl: Duration)
Set the TTL for new entries added to the cache.
Does not affect already-cached entries.
Sourcepub fn get(&self, host: &str, port: u16) -> Option<&[SocketAddr]>
pub fn get(&self, host: &str, port: u16) -> Option<&[SocketAddr]>
Look up a cached DNS entry for the given host and port.
Returns None if no entry exists or the entry has expired.
Sourcepub fn put(&mut self, host: &str, port: u16, addrs: Vec<SocketAddr>)
pub fn put(&mut self, host: &str, port: u16, addrs: Vec<SocketAddr>)
Store resolved addresses in the cache.
Sourcepub fn purge_expired(&mut self)
pub fn purge_expired(&mut self)
Remove expired entries from the cache.
Trait Implementations§
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