pub struct ConnectionCache<C> { /* private fields */ }Expand description
Thread-safe connection cache bound to exact host topology revisions.
The cache does not open or close connections. Drivers own those lifecycle actions and receive removed handles from invalidation and eviction methods.
Implementations§
Source§impl<C> ConnectionCache<C>
impl<C> ConnectionCache<C>
Sourcepub fn insert(&self, host: &HostRecord, connection: C) -> Option<Arc<C>>
pub fn insert(&self, host: &HostRecord, connection: C) -> Option<Arc<C>>
Inserts a connection for one exact host revision.
Returns the replaced handle when the same key already existed.
Sourcepub fn get(&self, host: &HostRecord) -> Option<Arc<C>>
pub fn get(&self, host: &HostRecord) -> Option<Arc<C>>
Returns a connection only when the host revision matches exactly.
Sourcepub fn remove(&self, host: &HostRecord) -> Option<Arc<C>>
pub fn remove(&self, host: &HostRecord) -> Option<Arc<C>>
Removes one exact host revision.
Sourcepub fn invalidate_host(&self, host: &HostId) -> Vec<Arc<C>>
pub fn invalidate_host(&self, host: &HostId) -> Vec<Arc<C>>
Removes every cached revision for one host.
Sourcepub fn retain_snapshot(&self, snapshot: &TopologySnapshot) -> Vec<Arc<C>>
pub fn retain_snapshot(&self, snapshot: &TopologySnapshot) -> Vec<Arc<C>>
Removes keys absent from the supplied topology snapshot.
A host whose endpoint changed has a new revision and therefore evicts the old cached connection even when its stable host identity is unchanged.
Trait Implementations§
Auto Trait Implementations§
impl<C> !Freeze for ConnectionCache<C>
impl<C> RefUnwindSafe for ConnectionCache<C>
impl<C> Send for ConnectionCache<C>
impl<C> Sync for ConnectionCache<C>
impl<C> Unpin for ConnectionCache<C>
impl<C> UnsafeUnpin for ConnectionCache<C>
impl<C> UnwindSafe for ConnectionCache<C>
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