pub struct RedisCache { /* private fields */ }Expand description
Redis L1.5 distributed cache
Implementations§
Source§impl RedisCache
impl RedisCache
Sourcepub async fn new(redis_url: &str) -> Result<Self, RedisError>
pub async fn new(redis_url: &str) -> Result<Self, RedisError>
Connect to Redis and create a new cache instance
Sourcepub async fn get(&self, namespace: &str, id: &str) -> Option<Vector>
pub async fn get(&self, namespace: &str, id: &str) -> Option<Vector>
Get a single vector from Redis
Sourcepub async fn get_multi(&self, namespace: &str, ids: &[String]) -> Vec<Vector>
pub async fn get_multi(&self, namespace: &str, ids: &[String]) -> Vec<Vector>
Get multiple vectors from Redis
Sourcepub async fn set(&self, namespace: &str, vector: &Vector)
pub async fn set(&self, namespace: &str, vector: &Vector)
Store a single vector in Redis with TTL
Sourcepub async fn set_batch(&self, namespace: &str, vectors: &[Vector])
pub async fn set_batch(&self, namespace: &str, vectors: &[Vector])
Store multiple vectors in Redis using pipeline
Sourcepub async fn invalidate_namespace(&self, namespace: &str)
pub async fn invalidate_namespace(&self, namespace: &str)
Invalidate all entries for a namespace using SCAN + DEL
Sourcepub async fn stats(&self) -> RedisCacheStats
pub async fn stats(&self) -> RedisCacheStats
Get Redis cache statistics from INFO command
Sourcepub async fn publish_invalidation(&self, msg: &CacheInvalidation)
pub async fn publish_invalidation(&self, msg: &CacheInvalidation)
Publish a cache invalidation message via Redis pub/sub
Sourcepub async fn publish_raw(&self, channel: &str, message: &str)
pub async fn publish_raw(&self, channel: &str, message: &str)
Publish a raw string message to any Redis channel. Used for backup cache invalidation and other cross-node signaling.
Sourcepub async fn subscribe_raw(
&self,
channel: &str,
) -> Result<Receiver<String>, RedisError>
pub async fn subscribe_raw( &self, channel: &str, ) -> Result<Receiver<String>, RedisError>
Subscribe to a Redis channel and return a receiver for raw string messages. Spawns a background task that listens for messages on the channel.
Sourcepub async fn subscribe_invalidations<F>(&self, handler: F)
pub async fn subscribe_invalidations<F>(&self, handler: F)
Subscribe to cache invalidation messages. This is a long-running async function that calls the handler for each message. Should be spawned as a background task.
Trait Implementations§
Source§impl Clone for RedisCache
impl Clone for RedisCache
Source§fn clone(&self) -> RedisCache
fn clone(&self) -> RedisCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RedisCache
impl !RefUnwindSafe for RedisCache
impl Send for RedisCache
impl Sync for RedisCache
impl Unpin for RedisCache
impl UnsafeUnpin for RedisCache
impl !UnwindSafe for RedisCache
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
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>
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>
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