pub struct CacheManager { /* private fields */ }Expand description
Cache manager for general-purpose caching
Uses ConnectionManager for multiplexed connections instead of creating a new connection per operation. This provides:
- Automatic reconnection on failure
- Efficient connection reuse
- No pool configuration complexity
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub fn new(config: &RedisConfig) -> Result<Self>
pub fn new(config: &RedisConfig) -> Result<Self>
Create a new cache manager
Sourcepub async fn set_string(&self, key: &str, value: &str) -> Result<()>
pub async fn set_string(&self, key: &str, value: &str) -> Result<()>
Set a string value in cache
Sourcepub async fn get_string(&self, key: &str) -> Result<Option<String>>
pub async fn get_string(&self, key: &str) -> Result<Option<String>>
Get a string value from cache
Sourcepub async fn set_json<T: Serialize>(&self, key: &str, value: &T) -> Result<()>
pub async fn set_json<T: Serialize>(&self, key: &str, value: &T) -> Result<()>
Set a JSON-serializable value in cache
Sourcepub async fn get_json<T: DeserializeOwned>(
&self,
key: &str,
) -> Result<Option<T>>
pub async fn get_json<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<T>>
Get a JSON-deserializable value from cache
Sourcepub async fn delete_many(&self, keys: &[&str]) -> Result<()>
pub async fn delete_many(&self, keys: &[&str]) -> Result<()>
Delete multiple cached values
Sourcepub async fn set_string_with_ttl(
&self,
key: &str,
value: &str,
ttl_seconds: u64,
) -> Result<()>
pub async fn set_string_with_ttl( &self, key: &str, value: &str, ttl_seconds: u64, ) -> Result<()>
Set with custom TTL
Sourcepub fn scoped_key(&self, namespace: &str, id: Uuid, product: &str) -> String
pub fn scoped_key(&self, namespace: &str, id: Uuid, product: &str) -> String
Helper: Create product-scoped key
Example: cache_key(“conversations”, user_id, “novaskyn”) -> “cache:novaskyn:conversations:{user_id}”
Sourcepub fn simple_key(&self, namespace: &str, product: &str) -> String
pub fn simple_key(&self, namespace: &str, product: &str) -> String
Helper: Create simple product-scoped key
Example: simple_key(“config”, “novaskyn”) -> “cache:novaskyn:config”
Trait Implementations§
Source§impl Clone for CacheManager
impl Clone for CacheManager
Source§fn clone(&self) -> CacheManager
fn clone(&self) -> CacheManager
Returns a duplicate of the value. Read more
1.0.0 · 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 !Freeze for CacheManager
impl !RefUnwindSafe for CacheManager
impl Send for CacheManager
impl Sync for CacheManager
impl Unpin for CacheManager
impl UnsafeUnpin for CacheManager
impl !UnwindSafe for CacheManager
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