pub struct RedisStore { /* private fields */ }Implementations§
Source§impl RedisStore
impl RedisStore
Sourcepub async fn new(connection_string: &str) -> Result<Self, StorageError>
pub async fn new(connection_string: &str) -> Result<Self, StorageError>
Create a new Redis store without a key prefix.
Sourcepub async fn with_prefix(
connection_string: &str,
prefix: Option<&str>,
) -> Result<Self, StorageError>
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?;Sourcepub fn connection(&self) -> ConnectionManager
pub fn connection(&self) -> ConnectionManager
Get a clone of the connection manager (for sharing with MerkleStore)
Source§impl RedisStore
impl RedisStore
Sourcepub async fn exists_batch(
&self,
ids: &[String],
) -> Result<Vec<bool>, StorageError>
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.
Sourcepub async fn list_state_ids(
&self,
state: &str,
) -> Result<Vec<String>, StorageError>
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().
Sourcepub async fn count_by_state(&self, state: &str) -> Result<u64, StorageError>
pub async fn count_by_state(&self, state: &str) -> Result<u64, StorageError>
Count items in a given state (SET cardinality).
Sourcepub async fn is_in_state(
&self,
id: &str,
state: &str,
) -> Result<bool, StorageError>
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).
Sourcepub async fn move_state(
&self,
id: &str,
from_state: &str,
to_state: &str,
) -> Result<bool, StorageError>
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.
Sourcepub async fn remove_from_state(
&self,
id: &str,
state: &str,
) -> Result<bool, StorageError>
pub async fn remove_from_state( &self, id: &str, state: &str, ) -> Result<bool, StorageError>
Remove an ID from a state SET.
Sourcepub async fn delete_by_state(&self, state: &str) -> Result<u64, StorageError>
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.
Sourcepub async fn scan_prefix(
&self,
prefix: &str,
limit: usize,
) -> Result<Vec<SyncItem>, StorageError>
pub async fn scan_prefix( &self, prefix: &str, limit: usize, ) -> Result<Vec<SyncItem>, StorageError>
Sourcepub async fn count_prefix(&self, prefix: &str) -> Result<u64, StorageError>
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.
Sourcepub async fn delete_prefix(&self, prefix: &str) -> Result<u64, StorageError>
pub async fn delete_prefix(&self, prefix: &str) -> Result<u64, StorageError>
Delete all items matching an ID prefix.
Returns the number of deleted items.
Sourcepub async fn xadd_cdc(
&self,
entry: &CdcEntry,
maxlen: u64,
) -> Result<String, StorageError>
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}:cdc.
Sourcepub async fn xadd_cdc_batch(
&self,
entries: &[CdcEntry],
maxlen: u64,
) -> Result<Vec<String>, StorageError>
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
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,
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,
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,
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,
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).
Source§fn ft_search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
index: &'life1 str,
query: &'life2 str,
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,
fn ft_search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
index: &'life1 str,
query: &'life2 str,
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,
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,
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
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,
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,
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,
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,
Auto Trait Implementations§
impl !RefUnwindSafe for RedisStore
impl !UnwindSafe for RedisStore
impl Freeze for RedisStore
impl Send for RedisStore
impl Sync for RedisStore
impl Unpin for RedisStore
impl UnsafeUnpin for RedisStore
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> 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