pub struct DistributedCache { /* private fields */ }Expand description
L3 Distributed Cache - Cache mesh with consistent hashing
Implementations§
Source§impl DistributedCache
impl DistributedCache
Sourcepub fn new(replication_factor: u32, peer_addrs: Vec<SocketAddr>) -> Self
pub fn new(replication_factor: u32, peer_addrs: Vec<SocketAddr>) -> Self
Create a new distributed cache
Sourcepub async fn get(&self, fingerprint: &QueryFingerprint) -> Option<CacheEntry>
pub async fn get(&self, fingerprint: &QueryFingerprint) -> Option<CacheEntry>
Get an entry from the distributed cache
Sourcepub async fn insert(&self, fingerprint: QueryFingerprint, entry: CacheEntry)
pub async fn insert(&self, fingerprint: QueryFingerprint, entry: CacheEntry)
Insert an entry into the distributed cache
Sourcepub fn add_peer(&self, addr: SocketAddr)
pub fn add_peer(&self, addr: SocketAddr)
Add a peer to the cache mesh
Sourcepub fn remove_peer(&self, addr: &SocketAddr)
pub fn remove_peer(&self, addr: &SocketAddr)
Remove a peer from the cache mesh
Sourcepub fn mark_unhealthy(&self, addr: &SocketAddr)
pub fn mark_unhealthy(&self, addr: &SocketAddr)
Mark peer as unhealthy
Sourcepub fn mark_healthy(&self, addr: &SocketAddr)
pub fn mark_healthy(&self, addr: &SocketAddr)
Mark peer as healthy
Sourcepub async fn invalidate(&self, fingerprint: &QueryFingerprint)
pub async fn invalidate(&self, fingerprint: &QueryFingerprint)
Invalidate an entry across the mesh
Sourcepub fn peer_addrs(&self) -> Vec<SocketAddr>
pub fn peer_addrs(&self) -> Vec<SocketAddr>
Get peer addresses
Sourcepub fn copy_valid_entries_to(&self, target: &DistributedCache)
pub fn copy_valid_entries_to(&self, target: &DistributedCache)
Copy valid entries to another cache (for branch merging)
Auto Trait Implementations§
impl !Freeze for DistributedCache
impl !RefUnwindSafe for DistributedCache
impl Send for DistributedCache
impl Sync for DistributedCache
impl Unpin for DistributedCache
impl UnsafeUnpin for DistributedCache
impl UnwindSafe for DistributedCache
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> 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