pub struct CachedDbAccess<TKey, TData, S = RandomState>
where TKey: Clone + Hash + Eq + Send + Sync, TData: Clone + Send + Sync + MemSizeEstimator,
{ /* private fields */ }
Expand description

A concurrent DB store access with typed caching.

Implementations§

source§

impl<TKey, TData, S> CachedDbAccess<TKey, TData, S>
where TKey: Clone + Hash + Eq + Send + Sync, TData: Clone + Send + Sync + MemSizeEstimator, S: BuildHasher + Default,

source

pub fn new(db: Arc<DB>, cache_policy: CachePolicy, prefix: Vec<u8>) -> Self

source

pub fn read_from_cache(&self, key: TKey) -> Option<TData>
where TKey: Copy + AsRef<[u8]>,

source

pub fn has(&self, key: TKey) -> Result<bool, StoreError>
where TKey: Clone + AsRef<[u8]>,

source

pub fn read(&self, key: TKey) -> Result<TData, StoreError>
where TKey: Clone + AsRef<[u8]> + ToString, TData: DeserializeOwned,

source

pub fn iterator( &self ) -> impl Iterator<Item = Result<(Box<[u8]>, TData), Box<dyn Error>>> + '_
where TKey: Clone + AsRef<[u8]>, TData: DeserializeOwned,

source

pub fn write( &self, writer: impl DbWriter, key: TKey, data: TData ) -> Result<(), StoreError>
where TKey: Clone + AsRef<[u8]>, TData: Serialize,

source

pub fn write_many( &self, writer: impl DbWriter, iter: &mut (impl Iterator<Item = (TKey, TData)> + Clone) ) -> Result<(), StoreError>
where TKey: Clone + AsRef<[u8]>, TData: Serialize,

source

pub fn write_many_without_cache( &self, writer: impl DbWriter, iter: &mut impl Iterator<Item = (TKey, TData)> ) -> Result<(), StoreError>
where TKey: Clone + AsRef<[u8]>, TData: Serialize,

Write directly from an iterator and do not cache any data. NOTE: this action also clears the cache

source

pub fn delete(&self, writer: impl DbWriter, key: TKey) -> Result<(), StoreError>
where TKey: Clone + AsRef<[u8]>,

source

pub fn delete_many( &self, writer: impl DbWriter, key_iter: &mut (impl Iterator<Item = TKey> + Clone) ) -> Result<(), StoreError>
where TKey: Clone + AsRef<[u8]>,

source

pub fn delete_all(&self, writer: impl DbWriter) -> Result<(), StoreError>
where TKey: Clone + AsRef<[u8]>,

Deletes all entries in the store using the underlying rocksdb delete_range operation

source

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>>> + '_
where TKey: Clone + AsRef<[u8]>, TData: DeserializeOwned,

A dynamic iterator that can iterate through a specific prefix / bucket, or from a certain start point.

source

pub fn prefix(&self) -> &[u8]

Trait Implementations§

source§

impl<TKey, TData, S: Clone> Clone for CachedDbAccess<TKey, TData, S>
where TKey: Clone + Hash + Eq + Send + Sync + Clone, TData: Clone + Send + Sync + MemSizeEstimator + Clone,

source§

fn clone(&self) -> CachedDbAccess<TKey, TData, S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<TKey, TData, S = RandomState> !RefUnwindSafe for CachedDbAccess<TKey, TData, S>

§

impl<TKey, TData, S> Send for CachedDbAccess<TKey, TData, S>
where S: Sync + Send,

§

impl<TKey, TData, S> Sync for CachedDbAccess<TKey, TData, S>
where S: Sync + Send,

§

impl<TKey, TData, S> Unpin for CachedDbAccess<TKey, TData, S>

§

impl<TKey, TData, S = RandomState> !UnwindSafe for CachedDbAccess<TKey, TData, S>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more