Struct pkarr::InMemoryPkarrCache
source · pub struct InMemoryPkarrCache { /* private fields */ }
Expand description
A thread safe wrapper around LruCache
Implementations§
source§impl InMemoryPkarrCache
impl InMemoryPkarrCache
sourcepub fn new(capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize) -> Self
Creats a new LRU
cache that holds at most cap
items.
Trait Implementations§
source§impl Clone for InMemoryPkarrCache
impl Clone for InMemoryPkarrCache
source§fn clone(&self) -> InMemoryPkarrCache
fn clone(&self) -> InMemoryPkarrCache
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for InMemoryPkarrCache
impl Debug for InMemoryPkarrCache
source§impl PkarrCache for InMemoryPkarrCache
impl PkarrCache for InMemoryPkarrCache
source§fn put(&self, target: &Id, signed_packet: &SignedPacket)
fn put(&self, target: &Id, signed_packet: &SignedPacket)
Puts SignedPacket, if a version of the packet already exists, and it has the same SignedPacket::as_bytes, then only SignedPacket::last_seen will be updated, otherwise the input will be cloned.
fn len(&self) -> usize
source§fn get(&self, key: &PkarrCacheKey) -> Option<SignedPacket>
fn get(&self, key: &PkarrCacheKey) -> Option<SignedPacket>
Reads SignedPacket from cache, while moving it to the head of the LRU list.
fn is_empty(&self) -> bool
source§fn get_read_only(&self, key: &PkarrCacheKey) -> Option<SignedPacket>
fn get_read_only(&self, key: &PkarrCacheKey) -> Option<SignedPacket>
Reads SignedPacket from cache, without changing the LRU list. Read more
Auto Trait Implementations§
impl Freeze for InMemoryPkarrCache
impl RefUnwindSafe for InMemoryPkarrCache
impl Send for InMemoryPkarrCache
impl Sync for InMemoryPkarrCache
impl Unpin for InMemoryPkarrCache
impl UnwindSafe for InMemoryPkarrCache
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