Struct redis::Client[][src]

pub struct Client { /* fields omitted */ }

The client type.

Implementations

impl Client[src]

The client acts as connector to the redis server. By itself it does not do much other than providing a convenient way to fetch a connection from it. In the future the plan is to provide a connection pool in the client.

When opening a client a URL in the following format should be used:

redis://host:port/db

Example usage::

let client = redis::Client::open("redis://127.0.0.1/").unwrap();
let con = client.get_connection().unwrap();

pub fn open<T: IntoConnectionInfo>(params: T) -> RedisResult<Client>[src]

Connects to a redis server and returns a client. This does not actually open a connection yet but it does perform some basic checks on the URL that might make the operation fail.

pub fn get_connection(&self) -> RedisResult<Connection>[src]

Instructs the client to actually connect to redis and returns a connection object. The connection object can be used to send commands to the server. This can fail with a variety of errors (like unreachable host) so it's important that you handle those errors.

pub fn get_connection_with_timeout(
    &self,
    timeout: Duration
) -> RedisResult<Connection>
[src]

Instructs the client to actually connect to redis with specified timeout and returns a connection object. The connection object can be used to send commands to the server. This can fail with a variety of errors (like unreachable host) so it's important that you handle those errors.

impl Client[src]

To enable async support you need to chose one of the supported runtimes and active its corresponding feature: tokio-comp or async-std-comp

pub async fn get_async_connection(&self) -> RedisResult<Connection>[src]

This is supported on crate feature aio only.

Returns an async connection from the client.

pub async fn get_tokio_connection(&self) -> RedisResult<Connection>[src]

This is supported on crate features aio and tokio-comp only.

Returns an async connection from the client.

pub async fn get_async_std_connection(&self) -> RedisResult<Connection>[src]

This is supported on crate features aio and async-std-comp only.

Returns an async connection from the client.

pub async fn get_multiplexed_async_connection(
    &self
) -> RedisResult<MultiplexedConnection>
[src]

This is supported on crate feature aio and (crate features tokio-comp or async-std-comp) only.

Returns an async connection from the client.

pub async fn get_multiplexed_tokio_connection(
    &self
) -> RedisResult<MultiplexedConnection>
[src]

This is supported on crate features aio and tokio-comp only.

Returns an async multiplexed connection from the client.

A multiplexed connection can be cloned, allowing requests to be be sent concurrently on the same underlying connection (tcp/unix socket).

pub async fn get_multiplexed_async_std_connection(
    &self
) -> RedisResult<MultiplexedConnection>
[src]

This is supported on crate features aio and async-std-comp only.

Returns an async multiplexed connection from the client.

A multiplexed connection can be cloned, allowing requests to be be sent concurrently on the same underlying connection (tcp/unix socket).

pub async fn create_multiplexed_tokio_connection(
    &self
) -> RedisResult<(MultiplexedConnection, impl Future<Output = ()>)>
[src]

This is supported on crate features aio and tokio-comp only.

Returns an async multiplexed connection from the client and a future which must be polled to drive any requests submitted to it (see get_multiplexed_tokio_connection).

A multiplexed connection can be cloned, allowing requests to be be sent concurrently on the same underlying connection (tcp/unix socket).

pub async fn create_multiplexed_async_std_connection(
    &self
) -> RedisResult<(MultiplexedConnection, impl Future<Output = ()>)>
[src]

This is supported on crate features aio and async-std-comp only.

Returns an async multiplexed connection from the client and a future which must be polled to drive any requests submitted to it (see get_multiplexed_tokio_connection).

A multiplexed connection can be cloned, allowing requests to be be sent concurrently on the same underlying connection (tcp/unix socket).

pub async fn get_tokio_connection_manager(
    &self
) -> RedisResult<ConnectionManager>
[src]

This is supported on crate features aio and connection-manager only.

Returns an async ConnectionManager from the client.

The connection manager wraps a MultiplexedConnection. If a command to that connection fails with a connection error, then a new connection is established in the background and the error is returned to the caller.

This means that on connection loss at least one command will fail, but the connection will be re-established automatically if possible. Please refer to the ConnectionManager docs for detailed reconnecting behavior.

A connection manager can be cloned, allowing requests to be be sent concurrently on the same underlying connection (tcp/unix socket).

Trait Implementations

impl Clone for Client[src]

impl ConnectionLike for Client[src]

impl Debug for Client[src]

impl ManageConnection for Client[src]

This is supported on crate feature r2d2 only.

type Connection = Connection

The connection type this manager deals with.

type Error = RedisError

The error type returned by Connections.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,