pub struct DnsCache { /* private fields */ }Expand description
DNS cache with LRU eviction
Caches DNS lookups to reduce latency. Thread-safe via Arc<Mutex<…>>.
Implementations§
Source§impl DnsCache
impl DnsCache
Sourcepub fn with_capacity(capacity: usize) -> Result<Self>
pub fn with_capacity(capacity: usize) -> Result<Self>
Create a new DNS cache with specified capacity
Sourcepub async fn lookup(&self, domain: &str) -> Result<Vec<IpAddr>>
pub async fn lookup(&self, domain: &str) -> Result<Vec<IpAddr>>
Lookup a domain, using cache if available
Returns a list of IP addresses for the domain. The first IP is typically the preferred address for connection.
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub async fn reset_stats(&self)
pub async fn reset_stats(&self)
Reset cache statistics
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more