pub struct Parameters { /* private fields */ }Expand description
The store behind the cache. A read within ttl of the last read or
write of the same key returns the cached value; a write or reset through
any handle in any process moves the namespace on, and every handle reads
afresh. Clones share the cache.
Implementations§
Source§impl Parameters
impl Parameters
Sourcepub fn with_cache(db: Db, cache: Cache) -> Self
pub fn with_cache(db: Db, cache: Cache) -> Self
A store over the application’s cache, so every process sees a write.
Sourcepub fn with_ttl(self, ttl: Duration) -> Self
pub fn with_ttl(self, ttl: Duration) -> Self
The same store with another lifetime for cached reads.
Sourcepub async fn get<T: DeserializeOwned>(&self, key: &str) -> CoreResult<Option<T>>
pub async fn get<T: DeserializeOwned>(&self, key: &str) -> CoreResult<Option<T>>
Reads a parameter as T, from the cache when fresh.
Sourcepub async fn get_or<T: DeserializeOwned>(
&self,
key: &str,
default: T,
) -> CoreResult<T>
pub async fn get_or<T: DeserializeOwned>( &self, key: &str, default: T, ) -> CoreResult<T>
Reads a parameter, or default when unset.
Sourcepub async fn set<T: Serialize + ?Sized>(
&self,
key: &str,
value: &T,
) -> CoreResult<()>
pub async fn set<T: Serialize + ?Sized>( &self, key: &str, value: &T, ) -> CoreResult<()>
Writes a parameter; every handle reads it afresh, this one at once.
Sourcepub async fn reset(&self, key: &str) -> CoreResult<bool>
pub async fn reset(&self, key: &str) -> CoreResult<bool>
Removes a parameter; every handle sees its absence.
Trait Implementations§
Source§impl Clone for Parameters
impl Clone for Parameters
Auto Trait Implementations§
impl !RefUnwindSafe for Parameters
impl !UnwindSafe for Parameters
impl Freeze for Parameters
impl Send for Parameters
impl Sync for Parameters
impl Unpin for Parameters
impl UnsafeUnpin for Parameters
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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