Skip to main content

RedisConnection

Trait RedisConnection 

Source
pub trait RedisConnection:
    Send
    + Sync
    + 'static {
    // Required methods
    fn run(&self, cmd: Cmd) -> BoxFuture<'_, RedisResult<Value>>;
    fn run_on_primary(
        &self,
        key: &str,
        cmd: Cmd,
    ) -> BoxFuture<'_, RedisResult<Value>>;
}
Expand description

A cloneable, task-shareable handle that runs one Redis command.

Implemented for [ConnectionManager], [MultiplexedConnection] and [ClusterConnection]. Test doubles implement it to observe dispatched arguments without a server. Every method borrows &self; implementations clone the underlying handle per command, which the redis crate’s handles make cheap.

Required Methods§

Source

fn run(&self, cmd: Cmd) -> BoxFuture<'_, RedisResult<Value>>

Run one command with the handle’s default routing.

Source

fn run_on_primary( &self, key: &str, cmd: Cmd, ) -> BoxFuture<'_, RedisResult<Value>>

Run one command that reads key, on the node that owns the key’s slot as a primary. Non-cluster handles have exactly one node and use their default routing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl RedisConnection for ClusterConnection

Source§

fn run_on_primary( &self, key: &str, cmd: Cmd, ) -> BoxFuture<'_, RedisResult<Value>>

Selecting the slot primary is explicit here because a stale replica could hide an invalidation fence when the client enabled replica reads.

Source§

fn run(&self, cmd: Cmd) -> BoxFuture<'_, RedisResult<Value>>

Source§

impl RedisConnection for ConnectionManager

Source§

fn run(&self, cmd: Cmd) -> BoxFuture<'_, RedisResult<Value>>

Source§

fn run_on_primary( &self, _key: &str, cmd: Cmd, ) -> BoxFuture<'_, RedisResult<Value>>

Source§

impl RedisConnection for MultiplexedConnection

Source§

fn run(&self, cmd: Cmd) -> BoxFuture<'_, RedisResult<Value>>

Source§

fn run_on_primary( &self, _key: &str, cmd: Cmd, ) -> BoxFuture<'_, RedisResult<Value>>

Implementors§