pub struct ProviderCache { /* private fields */ }Expand description
Provider record cache
Implementations§
Source§impl ProviderCache
impl ProviderCache
Sourcepub fn with_config(config: ProviderCacheConfig) -> Self
pub fn with_config(config: ProviderCacheConfig) -> Self
Create a new provider cache with custom configuration
Sourcepub fn get(&self, cid: &Cid) -> Option<Vec<PeerId>>
pub fn get(&self, cid: &Cid) -> Option<Vec<PeerId>>
Get providers for a CID from cache
Returns None if not cached or expired
Sourcepub fn has_providers(&self, cid: &Cid) -> bool
pub fn has_providers(&self, cid: &Cid) -> bool
Check if we have valid (non-expired) providers cached
Sourcepub fn needs_refresh(&self, cid: &Cid) -> bool
pub fn needs_refresh(&self, cid: &Cid) -> bool
Check if providers need refresh (expired or below minimum)
Sourcepub fn add_provider(&self, cid: &Cid, provider: PeerId)
pub fn add_provider(&self, cid: &Cid, provider: PeerId)
Add a single provider to an existing cache entry
Sourcepub fn remove_provider(&self, cid: &Cid, provider: &PeerId)
pub fn remove_provider(&self, cid: &Cid, provider: &PeerId)
Remove a provider from cache (e.g., when it disconnects)
Sourcepub fn invalidate(&self, cid: &Cid)
pub fn invalidate(&self, cid: &Cid)
Remove all entries for a CID
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Remove all expired entries
Sourcepub fn stats(&self) -> ProviderCacheStats
pub fn stats(&self) -> ProviderCacheStats
Get cache statistics
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ProviderCache
impl !RefUnwindSafe for ProviderCache
impl Send for ProviderCache
impl Sync for ProviderCache
impl Unpin for ProviderCache
impl UnwindSafe for ProviderCache
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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