pub struct CachedDbAccess<TKey, TData, S = RandomState>{ /* private fields */ }Expand description
A concurrent DB store access with typed caching.
Implementations§
Source§impl<TKey, TData, S> CachedDbAccess<TKey, TData, S>
impl<TKey, TData, S> CachedDbAccess<TKey, TData, S>
pub fn new(db: Arc<DB>, cache_policy: CachePolicy, prefix: Vec<u8>) -> Self
pub fn read_from_cache(&self, key: TKey) -> Option<TData>
pub fn has(&self, key: TKey) -> Result<bool, StoreError>
pub fn read(&self, key: TKey) -> Result<TData, StoreError>
pub fn iterator( &self, ) -> impl Iterator<Item = Result<(Box<[u8]>, TData), Box<dyn Error>>> + '_
pub fn write( &self, writer: impl DbWriter, key: TKey, data: TData, ) -> Result<(), StoreError>
pub fn write_many( &self, writer: impl DbWriter, iter: &mut (impl Iterator<Item = (TKey, TData)> + Clone), ) -> Result<(), StoreError>
Sourcepub fn write_many_without_cache(
&self,
writer: impl DbWriter,
iter: &mut impl Iterator<Item = (TKey, TData)>,
) -> Result<(), StoreError>
pub fn write_many_without_cache( &self, writer: impl DbWriter, iter: &mut impl Iterator<Item = (TKey, TData)>, ) -> Result<(), StoreError>
Write directly from an iterator and do not cache any data. NOTE: this action also clears the cache
pub fn delete(&self, writer: impl DbWriter, key: TKey) -> Result<(), StoreError>
pub fn delete_many( &self, writer: impl DbWriter, key_iter: &mut (impl Iterator<Item = TKey> + Clone), ) -> Result<(), StoreError>
Sourcepub fn delete_all(&self, writer: impl DbWriter) -> Result<(), StoreError>
pub fn delete_all(&self, writer: impl DbWriter) -> Result<(), StoreError>
Deletes all entries in the store using the underlying rocksdb delete_range operation
Sourcepub fn seek_iterator(
&self,
bucket: Option<&[u8]>,
seek_from: Option<TKey>,
limit: usize,
skip_first: bool,
) -> impl Iterator<Item = Result<(Box<[u8]>, TData), Box<dyn Error>>> + '_
pub fn seek_iterator( &self, bucket: Option<&[u8]>, seek_from: Option<TKey>, limit: usize, skip_first: bool, ) -> impl Iterator<Item = Result<(Box<[u8]>, TData), Box<dyn Error>>> + '_
A dynamic iterator that can iterate through a specific prefix / bucket, or from a certain start point.
pub fn prefix(&self) -> &[u8] ⓘ
Trait Implementations§
Source§impl<TKey, TData, S: Clone> Clone for CachedDbAccess<TKey, TData, S>
impl<TKey, TData, S: Clone> Clone for CachedDbAccess<TKey, TData, S>
Source§fn clone(&self) -> CachedDbAccess<TKey, TData, S>
fn clone(&self) -> CachedDbAccess<TKey, TData, S>
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<TKey, TData, S> Freeze for CachedDbAccess<TKey, TData, S>
impl<TKey, TData, S = RandomState> !RefUnwindSafe for CachedDbAccess<TKey, TData, S>
impl<TKey, TData, S> Send for CachedDbAccess<TKey, TData, S>
impl<TKey, TData, S> Sync for CachedDbAccess<TKey, TData, S>
impl<TKey, TData, S> Unpin for CachedDbAccess<TKey, TData, S>
impl<TKey, TData, S = RandomState> !UnwindSafe for CachedDbAccess<TKey, TData, S>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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