pub struct L2Cache { /* private fields */ }Expand description
L2 Cache using Redis
Implementations§
Source§impl L2Cache
impl L2Cache
Sourcepub async fn set_with_ttl(
&self,
key: &str,
value: Value,
ttl: Duration,
) -> Result<()>
pub async fn set_with_ttl( &self, key: &str, value: Value, ttl: Duration, ) -> Result<()>
Set value with custom TTL
Sourcepub async fn health_check(&self) -> bool
pub async fn health_check(&self) -> bool
Health check
Sourcepub async fn stream_add(
&self,
stream_key: &str,
fields: Vec<(String, String)>,
maxlen: Option<usize>,
) -> Result<String>
pub async fn stream_add( &self, stream_key: &str, fields: Vec<(String, String)>, maxlen: Option<usize>, ) -> Result<String>
Publish data to Redis Stream using XADD
§Arguments
stream_key- Name of the Redis Stream (e.g., “events_stream”)fields- Vec of field-value pairs to add to the streammaxlen- Optional maximum length for stream trimming (uses MAXLEN ~ for approximate trimming)
§Returns
The stream entry ID generated by Redis (e.g., “1234567890123-0”)
Sourcepub async fn stream_read_latest(
&self,
stream_key: &str,
count: usize,
) -> Result<Vec<(String, Vec<(String, String)>)>>
pub async fn stream_read_latest( &self, stream_key: &str, count: usize, ) -> Result<Vec<(String, Vec<(String, String)>)>>
Sourcepub async fn stream_read(
&self,
stream_key: &str,
last_id: &str,
count: usize,
block_ms: Option<usize>,
) -> Result<Vec<(String, Vec<(String, String)>)>>
pub async fn stream_read( &self, stream_key: &str, last_id: &str, count: usize, block_ms: Option<usize>, ) -> Result<Vec<(String, Vec<(String, String)>)>>
Read entries from Redis Stream using XREAD (blocking or non-blocking)
§Arguments
stream_key- Name of the Redis Streamlast_id- Last entry ID seen (use “0” to read from beginning, “$” for only new entries)count- Maximum number of entries to retrieveblock_ms- Optional blocking timeout in milliseconds (None for non-blocking)
§Returns
Vector of (entry_id, fields) tuples
Auto Trait Implementations§
impl Freeze for L2Cache
impl RefUnwindSafe for L2Cache
impl Send for L2Cache
impl Sync for L2Cache
impl Unpin for L2Cache
impl UnwindSafe for L2Cache
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