RedisStore

Struct RedisStore 

Source
pub struct RedisStore { /* private fields */ }

Implementations§

Source§

impl RedisStore

Source

pub async fn new(connection_string: &str) -> Result<Self, StorageError>

Create a new Redis store without a key prefix.

Source

pub async fn with_prefix( connection_string: &str, prefix: Option<&str>, ) -> Result<Self, StorageError>

Create a new Redis store with an optional key prefix.

The prefix is prepended to all keys, enabling namespacing when sharing a Redis instance with other applications.

§Example
// Keys will be prefixed: "myapp:user.alice", "myapp:config.app"
let store = RedisStore::with_prefix("redis://localhost", Some("myapp:")).await?;
Source

pub fn connection(&self) -> ConnectionManager

Get a clone of the connection manager (for sharing with MerkleStore)

Source

pub fn prefix(&self) -> &str

Get the configured prefix

Source§

impl RedisStore

Source

pub async fn exists_batch( &self, ids: &[String], ) -> Result<Vec<bool>, StorageError>

Check if multiple keys exist in Redis (pipelined). Returns a vec of bools matching the input order.

Source

pub async fn list_state_ids( &self, state: &str, ) -> Result<Vec<String>, StorageError>

Get all IDs in a given state (from Redis SET).

Returns IDs without prefix - ready to use with get().

Source

pub async fn count_by_state(&self, state: &str) -> Result<u64, StorageError>

Count items in a given state (SET cardinality).

Source

pub async fn is_in_state( &self, id: &str, state: &str, ) -> Result<bool, StorageError>

Check if an ID is in a given state (SET membership).

Source

pub async fn move_state( &self, id: &str, from_state: &str, to_state: &str, ) -> Result<bool, StorageError>

Move an ID from one state to another (atomic SMOVE).

Returns true if the item was moved, false if it wasn’t in the source state.

Source

pub async fn remove_from_state( &self, id: &str, state: &str, ) -> Result<bool, StorageError>

Remove an ID from a state SET.

Source

pub async fn delete_by_state(&self, state: &str) -> Result<u64, StorageError>

Delete all items in a state (both the SET and the actual keys).

Returns the number of items deleted.

Source

pub async fn scan_prefix( &self, prefix: &str, limit: usize, ) -> Result<Vec<SyncItem>, StorageError>

Scan items by ID prefix using Redis SCAN.

Uses cursor-based SCAN with MATCH pattern for safe iteration. Does NOT block the server (unlike KEYS).

§Example
// Get all deltas for object user.123
let deltas = store.scan_prefix("delta:user.123:", 1000).await?;
Source

pub async fn count_prefix(&self, prefix: &str) -> Result<u64, StorageError>

Count items matching an ID prefix.

Note: This requires scanning all matching keys, so use sparingly.

Source

pub async fn delete_prefix(&self, prefix: &str) -> Result<u64, StorageError>

Delete all items matching an ID prefix.

Returns the number of deleted items.

Source

pub async fn xadd_cdc( &self, entry: &CdcEntry, maxlen: u64, ) -> Result<String, StorageError>

Write a CDC entry to the stream.

Uses XADD with MAXLEN ~ for bounded stream size. The stream key is {prefix}__local__:cdc.

Source

pub async fn xadd_cdc_batch( &self, entries: &[CdcEntry], maxlen: u64, ) -> Result<Vec<String>, StorageError>

Write multiple CDC entries to the stream in a pipeline.

Returns the stream entry IDs for each write.

Trait Implementations§

Source§

impl CacheStore for RedisStore

Source§

fn put_batch<'life0, 'life1, 'async_trait>( &'life0 self, items: &'life1 [SyncItem], ) -> Pin<Box<dyn Future<Output = Result<BatchWriteResult, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Write a batch of items using Redis pipeline (atomic, much faster than individual SETs).

Source§

fn put_batch_with_ttl<'life0, 'life1, 'async_trait>( &'life0 self, items: &'life1 [SyncItem], ttl_secs: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<BatchWriteResult, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Write a batch of items with optional TTL.

Source§

fn ft_create<'life0, 'life1, 'async_trait>( &'life0 self, args: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a RediSearch index (FT.CREATE).

Source§

fn ft_dropindex<'life0, 'life1, 'async_trait>( &'life0 self, index: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Drop a RediSearch index (FT.DROPINDEX).

Search using RediSearch (FT.SEARCH).

Source§

fn ft_search_with_params<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, index: &'life1 str, query: &'life2 str, params: &'life3 [(String, Vec<u8>)], limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Search using RediSearch with binary parameters (for vector KNN search). Uses FT.SEARCH index query PARAMS n name blob… LIMIT offset count NOCONTENT

Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SyncItem>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn put<'life0, 'life1, 'async_trait>( &'life0 self, item: &'life1 SyncItem, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if an item exists (Redis EXISTS command - fast, no data transfer).

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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