RedisCache

Struct RedisCache 

Source
pub struct RedisCache { /* private fields */ }
Expand description

Redis caching operations

Implementations§

Source§

impl RedisCache

Source

pub fn new(client: ConnectionManager) -> Self

Create new Redis cache

Source

pub fn with_prefix(client: ConnectionManager, prefix: impl Into<String>) -> Self

Create new Redis cache with custom prefix

Source

pub async fn cache_embedding( &self, key: &str, embedding: &[f32], ) -> MemoryResult<()>

Cache an embedding vector

Source

pub async fn get_embedding(&self, key: &str) -> MemoryResult<Option<Vec<f32>>>

Get cached embedding

Source

pub async fn set<T: Serialize>(&self, key: &str, value: &T) -> MemoryResult<()>

Cache a serializable value with default TTL

Source

pub async fn set_with_ttl<T: Serialize>( &self, key: &str, value: &T, ttl_seconds: u64, ) -> MemoryResult<()>

Cache a serializable value with custom TTL

Source

pub async fn get<T: DeserializeOwned>( &self, key: &str, ) -> MemoryResult<Option<T>>

Get a cached value

Source

pub async fn invalidate(&self, key: &str) -> MemoryResult<()>

Invalidate cache key

Source

pub async fn invalidate_pattern(&self, pattern: &str) -> MemoryResult<u64>

Invalidate all keys matching a pattern

Source

pub async fn exists(&self, key: &str) -> MemoryResult<bool>

Check if a key exists

Source

pub async fn expire(&self, key: &str, ttl_seconds: u64) -> MemoryResult<bool>

Set expiration on an existing key

Source

pub async fn ttl(&self, key: &str) -> MemoryResult<i64>

Get TTL of a key

Source

pub async fn incr(&self, key: &str) -> MemoryResult<i64>

Increment a counter

Source

pub async fn set_session<T: Serialize>( &self, session_id: &str, data: &T, ) -> MemoryResult<()>

Store session data

Source

pub async fn get_session<T: DeserializeOwned>( &self, session_id: &str, ) -> MemoryResult<Option<T>>

Get session data

Source

pub async fn extend_session(&self, session_id: &str) -> MemoryResult<bool>

Extend session TTL

Source

pub async fn delete_session(&self, session_id: &str) -> MemoryResult<()>

Delete session

Source

pub async fn cache_user_memories( &self, user_id: &str, memory_type: &str, memory_ids: &[String], ) -> MemoryResult<()>

Cache user memory list

Source

pub async fn get_user_memories( &self, user_id: &str, memory_type: &str, ) -> MemoryResult<Option<Vec<String>>>

Get cached user memory list

Source

pub async fn invalidate_user_cache(&self, user_id: &str) -> MemoryResult<u64>

Invalidate user memory cache

Source

pub async fn ping(&self) -> MemoryResult<bool>

Ping Redis to check connectivity

Source

pub async fn info(&self) -> MemoryResult<String>

Get Redis info

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more