pub struct InMemoryCache { /* private fields */ }Expand description
A thread safe wrapper around lru::LruCache
Implementations§
Source§impl InMemoryCache
impl InMemoryCache
Sourcepub fn new(capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize) -> Self
Creates a new LRU cache that holds at most cap items.
Trait Implementations§
Source§impl Cache for InMemoryCache
impl Cache for InMemoryCache
Source§fn put(&self, key: &CacheKey, signed_packet: &SignedPacket)
fn put(&self, key: &CacheKey, 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.
Source§fn capacity(&self) -> usize
fn capacity(&self) -> usize
Returns the maximum capacity of SignedPackets allowed in this cache.
Source§fn len(&self) -> usize
fn len(&self) -> usize
Returns the number of SignedPackets in this cache.
Source§fn get(&self, key: &CacheKey) -> Option<SignedPacket>
fn get(&self, key: &CacheKey) -> Option<SignedPacket>
Reads SignedPacket from cache, while moving it to the head of the LRU list.
Source§fn get_read_only(&self, key: &CacheKey) -> Option<SignedPacket>
fn get_read_only(&self, key: &CacheKey) -> Option<SignedPacket>
Reads SignedPacket from cache, without changing the LRU list. Read more
Source§impl Clone for InMemoryCache
impl Clone for InMemoryCache
Source§fn clone(&self) -> InMemoryCache
fn clone(&self) -> InMemoryCache
Returns a duplicate 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 moreAuto Trait Implementations§
impl Freeze for InMemoryCache
impl RefUnwindSafe for InMemoryCache
impl Send for InMemoryCache
impl Sync for InMemoryCache
impl Unpin for InMemoryCache
impl UnsafeUnpin for InMemoryCache
impl UnwindSafe for InMemoryCache
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