pub struct CacheStore { /* private fields */ }Expand description
The application’s handle on the cache.
Holds an Arc<dyn Cache> so the driver is a boot-time decision, and is
itself a Cache, so a handler can call cache.remember(...) on it
directly without unwrapping anything.
Implementations§
Source§impl CacheStore
impl CacheStore
Sourcepub fn from_config(config: &Config) -> Result<Self>
pub fn from_config(config: &Config) -> Result<Self>
Build the driver named in the application configuration.
Deliberately synchronous and non-connecting: an application must boot
even when Redis is momentarily down. Call CacheStore::verify when
failing fast is what you want instead.
pub fn build(settings: &CacheConfig) -> Result<Self>
Sourcepub fn from_driver(store: impl Cache) -> Self
pub fn from_driver(store: impl Cache) -> Self
Wrap a driver that was built by hand.
Sourcepub fn driver_handle(&self) -> Arc<dyn Cache> ⓘ
pub fn driver_handle(&self) -> Arc<dyn Cache> ⓘ
The underlying driver, for a caller that needs Arc<dyn Cache>.
Trait Implementations§
Source§impl Cache for CacheStore
Delegation, so CacheStore is usable everywhere a Cache is — including
picking up every default method and all of CacheExt.
impl Cache for CacheStore
Delegation, so CacheStore is usable everywhere a Cache is — including
picking up every default method and all of CacheExt.
Source§fn driver(&self) -> &'static str
fn driver(&self) -> &'static str
The driver’s name, used in
cache.hit / cache.miss events and in
error messages. Telescope shows it as the store column.Source§fn get<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<Option<Json>>>
fn get<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<Option<Json>>>
Fetch a value, or
None when it is missing or expired. Read moreSource§fn put<'a>(
&'a self,
key: &'a str,
value: Json,
ttl: Duration,
) -> BoxFuture<'a, Result<()>>
fn put<'a>( &'a self, key: &'a str, value: Json, ttl: Duration, ) -> BoxFuture<'a, Result<()>>
Store a value that expires after
ttl. Read moreSource§fn forever<'a>(&'a self, key: &'a str, value: Json) -> BoxFuture<'a, Result<()>>
fn forever<'a>(&'a self, key: &'a str, value: Json) -> BoxFuture<'a, Result<()>>
Store a value with no expiry. It still goes away on
Cache::flush.Source§fn forget<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<bool>>
fn forget<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<bool>>
Remove a key. Returns whether something was actually there.
Source§fn has<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<bool>>
fn has<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<bool>>
Whether a live (unexpired) value exists.
Source§fn increment<'a>(&'a self, key: &'a str, by: i64) -> BoxFuture<'a, Result<i64>>
fn increment<'a>(&'a self, key: &'a str, by: i64) -> BoxFuture<'a, Result<i64>>
Add
by to a counter, creating it at zero first. Returns the new value. Read moreSource§fn decrement<'a>(&'a self, key: &'a str, by: i64) -> BoxFuture<'a, Result<i64>>
fn decrement<'a>(&'a self, key: &'a str, by: i64) -> BoxFuture<'a, Result<i64>>
Subtract
by from a counter. Returns the new value.Source§fn increment_within<'a>(
&'a self,
key: &'a str,
by: i64,
ttl: Duration,
) -> BoxFuture<'a, Result<i64>>
fn increment_within<'a>( &'a self, key: &'a str, by: i64, ttl: Duration, ) -> BoxFuture<'a, Result<i64>>
Increment a counter, giving it
ttl only when this call created it. Read moreSource§impl Clone for CacheStore
impl Clone for CacheStore
Source§fn clone(&self) -> CacheStore
fn clone(&self) -> CacheStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for CacheStore
impl !UnwindSafe for CacheStore
impl Freeze for CacheStore
impl Send for CacheStore
impl Sync for CacheStore
impl Unpin for CacheStore
impl UnsafeUnpin for CacheStore
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