pub trait AsyncCommands:
ConnectionLike
+ Send
+ Sized {
Show 22 methods
// Provided methods
fn eappend<'a, S: ToRedisArgs + Send + Sync + 'a, E: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
event_name: E,
options: EAppendOptions<'a>,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn emappend<'a, RV>(
&'a mut self,
partition_key: Uuid,
events: &'a [EMAppendEvent<'a>],
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn eget<'a, RV>(&'a mut self, event_id: Uuid) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn epscan_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
start_sequence: u64,
end_sequence: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn epscan_by_id<'a, RV>(
&'a mut self,
partition_id: u16,
start_sequence: u64,
end_sequence: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn escan<'a, RV>(
&'a mut self,
stream_id: &'a str,
start_version: u64,
end_version: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn escan_with_partition_key<'a, RV>(
&'a mut self,
stream_id: &'a str,
partition_key: Uuid,
start_version: u64,
end_version: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn epseq_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn epseq_by_id<'a, RV>(
&'a mut self,
partition_id: u16,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn esver<'a, RV>(&'a mut self, stream_id: &'a str) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn esver_with_partition_key<'a, RV>(
&'a mut self,
stream_id: &'a str,
partition_key: Uuid,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn esub<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn esub_with_partition_key<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
partition_key: Uuid,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn esub_from_version<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
from_version: u64,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn esub_with_partition_and_version<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
partition_key: Uuid,
from_version: u64,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn epsub_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn epsub_by_id<'a, RV>(
&'a mut self,
partition_id: u16,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn epsub_by_key_from_sequence<'a, RV>(
&'a mut self,
partition_key: Uuid,
from_sequence: u64,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn epsub_by_id_from_sequence<'a, RV>(
&'a mut self,
partition_id: u16,
from_sequence: u64,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn hello<'a, RV>(&'a mut self, version: u32) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn ping<'a, RV>(&'a mut self) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
fn eack<'a, RV>(
&'a mut self,
subscription_id: Uuid,
cursor: u64,
) -> RedisFuture<'a, RV>
where RV: FromRedisValue { ... }
}Expand description
Implements common redis commands over asynchronous connections.
This allows you to send commands straight to a connection or client.
This allows you to use nicer syntax for some common operations. For instance this code:
use redis::AsyncCommands;
let client = redis::Client::open("redis://127.0.0.1/")?;
let mut con = client.get_multiplexed_async_connection().await?;
redis::cmd("SET").arg("my_key").arg(42i32).exec_async(&mut con).await?;
assert_eq!(redis::cmd("GET").arg("my_key").query_async(&mut con).await, Ok(42i32));Will become this:
use redis::AsyncCommands;
use redis::Commands;
let client = redis::Client::open("redis://127.0.0.1/")?;
let mut con = client.get_multiplexed_async_connection().await?;
let _: () = con.set("my_key", 42i32).await?;
assert_eq!(con.get("my_key").await, Ok(42i32));Provided Methods§
Sourcefn eappend<'a, S: ToRedisArgs + Send + Sync + 'a, E: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
event_name: E,
options: EAppendOptions<'a>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn eappend<'a, S: ToRedisArgs + Send + Sync + 'a, E: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
event_name: E,
options: EAppendOptions<'a>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Append an event to a stream.
§Parameters
stream_id: Stream identifier to append the event toevent_name: Name/type of the eventoptions: Configuration for optional parameters (event_id, partition_key, expected_version, payload, metadata)
§Example
let options = EAppendOptions::new()
.payload(br#"{"name":"john"}"#)
.metadata(br#"{"source":"api"}"#);
conn.eappend("my-stream", "UserCreated", options)?;§Returns
Returns an AppendInfo containing event metadata.
Sourcefn emappend<'a, RV>(
&'a mut self,
partition_key: Uuid,
events: &'a [EMAppendEvent<'a>],
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn emappend<'a, RV>(
&'a mut self,
partition_key: Uuid,
events: &'a [EMAppendEvent<'a>],
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Append multiple events to streams in a single transaction.
§Parameters
partition_key: UUID that determines which partition all events will be written toevents: Array of events to append, each with their own configuration
§Example
let events = [
EMAppendEvent::new("stream1", "EventA").payload(br#"{"data":"value1"}"#),
EMAppendEvent::new("stream2", "EventB").payload(br#"{"data":"value2"}"#),
];
conn.emappend(partition_key, &events)?;Note: All events are appended atomically in a single transaction.
§Returns
Returns transaction result information.
Sourcefn eget<'a, RV>(&'a mut self, event_id: Uuid) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn eget<'a, RV>(&'a mut self, event_id: Uuid) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Sourcefn epscan_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
start_sequence: u64,
end_sequence: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn epscan_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
start_sequence: u64,
end_sequence: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Scan events in a partition by partition key.
§Parameters
partition_key: UUID key to determine which partition to scanstart_sequence: Starting sequence numberend_sequence: Ending sequence number (Nonemeans scan to end)count: Maximum number of events to return (defaults to 100)
§Example
let partition_key = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let batch = conn.epscan_by_key(partition_key, 0, Some(100), Some(50))?;§Returns
Returns an EventBatch containing events and pagination info.
Sourcefn epscan_by_id<'a, RV>(
&'a mut self,
partition_id: u16,
start_sequence: u64,
end_sequence: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn epscan_by_id<'a, RV>(
&'a mut self,
partition_id: u16,
start_sequence: u64,
end_sequence: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Scan events in a partition by partition ID.
§Parameters
partition_id: Numeric partition identifier (0-65535)start_sequence: Starting sequence numberend_sequence: Ending sequence number (Nonemeans scan to end)count: Maximum number of events to return (defaults to 100)
§Example
let batch = conn.epscan_by_id(42, 100, Some(200), Some(50))?;§Returns
Returns an EventBatch containing events and pagination info.
Sourcefn escan<'a, RV>(
&'a mut self,
stream_id: &'a str,
start_version: u64,
end_version: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn escan<'a, RV>(
&'a mut self,
stream_id: &'a str,
start_version: u64,
end_version: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Scan events in a stream by stream ID.
§Parameters
stream_id: Stream identifier to scanstart_version: Starting version numberend_version: Ending version number (Nonemeans scan to end)count: Maximum number of events to return (defaults to 100)
§Example
let events = conn.escan("my-stream", 0, Some(100), Some(50))?;§Returns
Returns events from the stream across all partitions.
Sourcefn escan_with_partition_key<'a, RV>(
&'a mut self,
stream_id: &'a str,
partition_key: Uuid,
start_version: u64,
end_version: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn escan_with_partition_key<'a, RV>(
&'a mut self,
stream_id: &'a str,
partition_key: Uuid,
start_version: u64,
end_version: Option<u64>,
count: Option<u64>,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Scan events in a stream by stream ID within a specific partition.
§Parameters
stream_id: Stream identifier to scanpartition_key: UUID to scan within a specific partition onlystart_version: Starting version numberend_version: Ending version number (Nonemeans scan to end)count: Maximum number of events to return (defaults to 100)
§Example
let partition_key = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let batch = conn.escan_with_partition_key("my-stream", partition_key, 0, Some(100), Some(50))?;§Returns
Returns an EventBatch containing events from the specified partition only.
Sourcefn epseq_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn epseq_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Get the current sequence number for a partition by partition key.
§Parameters
partition_key: UUID key to determine which partition to query
§Example
let partition_key = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let sequence = conn.epseq_by_key(partition_key)?;§Returns
Returns the current sequence number for the partition.
Sourcefn epseq_by_id<'a, RV>(&'a mut self, partition_id: u16) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn epseq_by_id<'a, RV>(&'a mut self, partition_id: u16) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Sourcefn esver<'a, RV>(&'a mut self, stream_id: &'a str) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn esver<'a, RV>(&'a mut self, stream_id: &'a str) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Sourcefn esver_with_partition_key<'a, RV>(
&'a mut self,
stream_id: &'a str,
partition_key: Uuid,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn esver_with_partition_key<'a, RV>(
&'a mut self,
stream_id: &'a str,
partition_key: Uuid,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Get the current version number for a stream within a specific partition.
§Parameters
stream_id: Stream identifier to get version forpartition_key: UUID to check specific partition
§Example
let partition_key = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let version = conn.esver_with_partition_key("my-stream", partition_key)?;§Returns
Returns the current version number for the stream in the specified partition.
Sourcefn esub<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn esub<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Sourcefn esub_with_partition_key<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
partition_key: Uuid,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn esub_with_partition_key<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
partition_key: Uuid,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Subscribe to events from a stream with partition key.
§Parameters
stream_id: Stream identifier to subscribe topartition_key: UUID to subscribe to specific partition
§Example
let partition_key = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let subscription = conn.esub_with_partition_key("my-stream", partition_key)?;§Returns
Returns subscription information.
Sourcefn esub_from_version<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
from_version: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn esub_from_version<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
from_version: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Sourcefn esub_with_partition_and_version<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
partition_key: Uuid,
from_version: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn esub_with_partition_and_version<'a, S: ToRedisArgs + Send + Sync + 'a, RV>(
&'a mut self,
stream_id: S,
partition_key: Uuid,
from_version: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Subscribe to events from a stream with partition key and version.
§Parameters
stream_id: Stream identifier to subscribe topartition_key: UUID to subscribe to specific partitionfrom_version: Starting version number
§Example
let partition_key = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let subscription = conn.esub_with_partition_and_version("my-stream", partition_key, 100)?;§Returns
Returns subscription information.
Sourcefn epsub_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn epsub_by_key<'a, RV>(
&'a mut self,
partition_key: Uuid,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Subscribe to events from a partition by partition key.
§Parameters
partition_key: UUID key to determine which partition to subscribe to
§Example
let partition_key = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let subscription = conn.epsub_by_key(partition_key)?;§Returns
Returns subscription information.
Sourcefn epsub_by_id<'a, RV>(&'a mut self, partition_id: u16) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn epsub_by_id<'a, RV>(&'a mut self, partition_id: u16) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Sourcefn epsub_by_key_from_sequence<'a, RV>(
&'a mut self,
partition_key: Uuid,
from_sequence: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn epsub_by_key_from_sequence<'a, RV>(
&'a mut self,
partition_key: Uuid,
from_sequence: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Subscribe to events from a partition by partition key, starting from a specific sequence.
§Parameters
partition_key: UUID key to determine which partition to subscribe tofrom_sequence: Start streaming from this sequence number
§Example
let partition_key = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
let subscription = conn.epsub_by_key_from_sequence(partition_key, 1000)?;§Returns
Returns subscription information.
Sourcefn epsub_by_id_from_sequence<'a, RV>(
&'a mut self,
partition_id: u16,
from_sequence: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn epsub_by_id_from_sequence<'a, RV>(
&'a mut self,
partition_id: u16,
from_sequence: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Subscribe to events from a partition by partition ID, starting from a specific sequence.
§Parameters
partition_id: Numeric partition identifier (0-65535)from_sequence: Start streaming from this sequence number
§Example
let subscription = conn.epsub_by_id_from_sequence(42, 1000)?;§Returns
Returns subscription information.
Sourcefn hello<'a, RV>(&'a mut self, version: u32) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn hello<'a, RV>(&'a mut self, version: u32) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Sourcefn ping<'a, RV>(&'a mut self) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn ping<'a, RV>(&'a mut self) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Sourcefn eack<'a, RV>(
&'a mut self,
subscription_id: Uuid,
cursor: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
fn eack<'a, RV>(
&'a mut self,
subscription_id: Uuid,
cursor: u64,
) -> RedisFuture<'a, RV>where
RV: FromRedisValue,
Acknowledge events up to a specific cursor for a subscription.
§Parameters
subscription_id: UUID of the subscriptioncursor: Cursor number to acknowledge up to
§Example
let subscription_id = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")?;
conn.eack(subscription_id, 100)?;§Returns
Returns “OK” on success.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl<T> AsyncCommands for T
aio only.