pub struct LmdbCache { /* private fields */ }Expand description
Persistent crate::Cache implementation using LMDB’s bindings heed
Implementations§
Source§impl LmdbCache
impl LmdbCache
Sourcepub unsafe fn open(env_path: &Path, capacity: usize) -> Result<Self, Error>
pub unsafe fn open(env_path: &Path, capacity: usize) -> Result<Self, Error>
Creates a new LmdbCache at the env_path and set the heed::EnvOpenOptions::map_size
to a multiple of the capacity by SignedPacket::MAX_BYTES, aligned to system’s page size,
a maximum of 10 TB, and a minimum of 10 MB.
§Safety
LmdbCache uses LMDB, opening which is marked unsafe, because the possible Undefined Behavior (UB) if the lock file is broken.
Sourcepub fn open_unsafe(env_path: &Path, capacity: usize) -> Result<Self, Error>
pub fn open_unsafe(env_path: &Path, capacity: usize) -> Result<Self, Error>
Convenient wrapper around Self::open.
Make sure to read the safety section in Self::open
Trait Implementations§
Source§impl Cache for LmdbCache
impl Cache for LmdbCache
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 put(&self, key: &CacheKey, signed_packet: &SignedPacket)
fn put(&self, key: &CacheKey, signed_packet: &SignedPacket)
Puts SignedPacket into 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
Auto Trait Implementations§
impl Freeze for LmdbCache
impl RefUnwindSafe for LmdbCache
impl Send for LmdbCache
impl Sync for LmdbCache
impl Unpin for LmdbCache
impl UnsafeUnpin for LmdbCache
impl UnwindSafe for LmdbCache
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