Struct concread::arcache::ARCacheReadTxn

source ·
pub struct ARCacheReadTxn<'a, K, V, S>
where K: Hash + Eq + Ord + Clone + Debug + Sync + Send + 'static, V: Clone + Debug + Sync + Send + 'static, S: ARCacheReadStat + Clone,
{ /* private fields */ }
Expand description

An active read transaction over the cache. The data is this cache is guaranteed to be valid at the point in time the read is created. You may include items during a cache miss via the “insert” function.

Implementations§

source§

impl<K: Hash + Eq + Ord + Clone + Debug + Sync + Send + 'static, V: Clone + Debug + Sync + Send + 'static, S: ARCacheReadStat + Clone> ARCacheReadTxn<'_, K, V, S>

source

pub fn get<Q>(&mut self, k: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + Ord + ?Sized,

Attempt to retieve a k-v pair from the cache. If it is present in the main cache OR the thread local cache, a Some is returned, else you will recieve a None. On a None, you must then consult the external data source that this structure is acting as a cache for.

source

pub fn contains_key<Q>(&mut self, k: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + Ord + ?Sized,

Determine if this cache contains the following key.

source

pub fn insert_sized(&mut self, k: K, v: V, size: NonZeroUsize)

Insert an item to the cache, with an associated weight/size factor. See also insert

source

pub fn insert(&mut self, k: K, v: V)

Add a value to the cache. This may be because you have had a cache miss and now wish to include in the thread local storage.

Note that is invalid to insert an item who’s key already exists in this thread local cache, and this is asserted IE will panic if you attempt this. It is also invalid for you to insert a value that does not match the source-of-truth state, IE inserting a different value than another thread may percieve. This is a read thread, so you should only be adding values that are relevant to this read transaction and this point in time. If you do not heed this warning, you may alter the fabric of time and space and have some interesting distortions in your data over time.

source

pub fn finish(self) -> S

_

Trait Implementations§

source§

impl<K: Hash + Eq + Ord + Clone + Debug + Sync + Send + 'static, V: Clone + Debug + Sync + Send + 'static, S: ARCacheReadStat + Clone> Drop for ARCacheReadTxn<'_, K, V, S>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<K: Hash + Eq + Ord + Clone + Debug + Sync + Send + 'static, V: Clone + Debug + Sync + Send + 'static, S: ARCacheReadStat + Clone + Sync + Send + 'static> Send for ARCacheReadTxn<'_, K, V, S>

source§

impl<K: Hash + Eq + Ord + Clone + Debug + Sync + Send + 'static, V: Clone + Debug + Sync + Send + 'static, S: ARCacheReadStat + Clone + Sync + Send + 'static> Sync for ARCacheReadTxn<'_, K, V, S>

Auto Trait Implementations§

§

impl<'a, K, V, S> Freeze for ARCacheReadTxn<'a, K, V, S>
where S: Freeze,

§

impl<'a, K, V, S> RefUnwindSafe for ARCacheReadTxn<'a, K, V, S>

§

impl<'a, K, V, S> Unpin for ARCacheReadTxn<'a, K, V, S>
where S: Unpin, K: Unpin,

§

impl<'a, K, V, S> UnwindSafe for ARCacheReadTxn<'a, K, V, 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
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.

source§

impl<T> Instrument for T

source§

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

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

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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