pub trait ThreadSafeCacheStore<'lock>where
Self: 'lock,{
type Key;
type Value;
type SLock<'guard>: From<&'guard Self::XLock>
where 'lock: 'guard;
type XLock: 'lock;
// Required methods
fn ts_get(&'lock self, handle: &Self::SLock<'_>) -> Option<Self::Value>;
fn ts_set(&'lock self, handle: &mut Self::XLock, value: &Self::Value);
fn ts_xlock(&'lock self, key: &Self::Key) -> Self::XLock;
fn ts_slock(&'lock self, key: &Self::Key) -> Self::SLock<'lock>;
fn ts_xlock_nblock(&'lock self, key: &Self::Key) -> Self::XLock;
fn ts_slock_nblock(&'lock self, key: &Self::Key) -> Self::SLock<'lock>;
// Provided methods
fn ts_exists(&'lock self, handle: &Self::SLock<'_>) -> bool { ... }
fn ts_one_get(&'lock self, key: &Self::Key) -> Option<Self::Value> { ... }
fn ts_one_set(&'lock self, key: &Self::Key, value: &Self::Value) { ... }
fn ts_one_exists(&'lock self, key: &Self::Key) -> bool { ... }
}
Expand description
Trait for a thread safe infallible cache store, analogous to CacheStore
Required Associated Types§
type Key
type Value
Required Methods§
Sourcefn ts_get(&'lock self, handle: &Self::SLock<'_>) -> Option<Self::Value>
fn ts_get(&'lock self, handle: &Self::SLock<'_>) -> Option<Self::Value>
Returns an option of the owned cache element if present.
Sourcefn ts_set(&'lock self, handle: &mut Self::XLock, value: &Self::Value)
fn ts_set(&'lock self, handle: &mut Self::XLock, value: &Self::Value)
Sets a value given its key.
Sourcefn ts_xlock(&'lock self, key: &Self::Key) -> Self::XLock
fn ts_xlock(&'lock self, key: &Self::Key) -> Self::XLock
Exclusively lock a key until the handle is dropped.
Sourcefn ts_slock(&'lock self, key: &Self::Key) -> Self::SLock<'lock>
fn ts_slock(&'lock self, key: &Self::Key) -> Self::SLock<'lock>
Acquire a shared lock of a key until the handle is dropped.
Sourcefn ts_xlock_nblock(&'lock self, key: &Self::Key) -> Self::XLock
fn ts_xlock_nblock(&'lock self, key: &Self::Key) -> Self::XLock
Exclusively lock a key until the handle is dropped. Non blocking.
Sourcefn ts_slock_nblock(&'lock self, key: &Self::Key) -> Self::SLock<'lock>
fn ts_slock_nblock(&'lock self, key: &Self::Key) -> Self::SLock<'lock>
Acquire a shared lock of a key until the handle is dropped. Non blocking.
Provided Methods§
Sourcefn ts_one_get(&'lock self, key: &Self::Key) -> Option<Self::Value>
fn ts_one_get(&'lock self, key: &Self::Key) -> Option<Self::Value>
Same as ts_get
but it performs a one-time lock
Sourcefn ts_one_set(&'lock self, key: &Self::Key, value: &Self::Value)
fn ts_one_set(&'lock self, key: &Self::Key, value: &Self::Value)
Same as ts_set
but it performs a one-time lock
Sourcefn ts_one_exists(&'lock self, key: &Self::Key) -> bool
fn ts_one_exists(&'lock self, key: &Self::Key) -> bool
Same as ts_exists
but it performs a one-time lock
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.