pub struct RedisStorageAccess { /* private fields */ }Expand description
Region-scoped Redis cache storing JSON-serialized values with a TTL.
Each region namespaces its keys with a per-region prefix; entries expire after the configured TTL (default 3600 seconds).
Implementations§
Source§impl RedisStorageAccess
impl RedisStorageAccess
Sourcepub fn new(storage: RedisStorage, region_name: &str) -> Self
pub fn new(storage: RedisStorage, region_name: &str) -> Self
Creates a region cache over the given storage with the default 3600-second TTL.
Sourcepub fn from_url(url: &str, region_name: &str) -> RedisResult<Self>
pub fn from_url(url: &str, region_name: &str) -> RedisResult<Self>
Creates a region cache from a Redis URL and region name.
Sourcepub async fn contains_async<K: ToString + Send + Sync>(
&self,
key: &K,
) -> RedisResult<bool>
pub async fn contains_async<K: ToString + Send + Sync>( &self, key: &K, ) -> RedisResult<bool>
Returns true when a cached entry exists for key.
Sourcepub async fn get_from_cache_async<K, V>(
&self,
key: &K,
) -> RedisResult<Option<V>>
pub async fn get_from_cache_async<K, V>( &self, key: &K, ) -> RedisResult<Option<V>>
Reads and JSON-decodes the entry for key; returns None when absent or undecodable.
K is the key type; V is the value type.
Sourcepub async fn put_into_cache_async<K, V>(
&self,
key: &K,
value: &V,
) -> RedisResult<()>
pub async fn put_into_cache_async<K, V>( &self, key: &K, value: &V, ) -> RedisResult<()>
JSON-encodes value and stores it under key with the region TTL.
K is the key type; V is the value type. Returns a Redis error when serialization fails.
Sourcepub async fn remove_from_cache_async<K: ToString + Send + Sync>(
&self,
key: &K,
) -> RedisResult<()>
pub async fn remove_from_cache_async<K: ToString + Send + Sync>( &self, key: &K, ) -> RedisResult<()>
Removes the entry for key, if present.
Sourcepub async fn clear_cache_async(&self) -> RedisResult<()>
pub async fn clear_cache_async(&self) -> RedisResult<()>
Removes all entries in this region via scan plus unlink.
Trait Implementations§
Source§impl<K, V> StorageAccess<K, V> for RedisStorageAccess
impl<K, V> StorageAccess<K, V> for RedisStorageAccess
Source§fn invalidate(&self, key: &K)
fn invalidate(&self, key: &K)
Removes the entry for
key, if present.Auto Trait Implementations§
impl Freeze for RedisStorageAccess
impl RefUnwindSafe for RedisStorageAccess
impl Send for RedisStorageAccess
impl Sync for RedisStorageAccess
impl Unpin for RedisStorageAccess
impl UnsafeUnpin for RedisStorageAccess
impl UnwindSafe for RedisStorageAccess
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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