[][src]Struct redis_r2d2::RedisConnectionManager

pub struct RedisConnectionManager { /* fields omitted */ }

An r2d2::ConnectionManager for redis::Clients.

Example

use std::ops::DerefMut;
use std::thread;

use redis_r2d2::{r2d2, redis, RedisConnectionManager};

fn main() {
    let manager = RedisConnectionManager::new("redis://localhost").unwrap();
    let pool = r2d2::Pool::builder()
        .build(manager)
        .unwrap();

    let mut handles = vec![];

    for _i in 0..10i32 {
        let pool = pool.clone();
        handles.push(thread::spawn(move || {
            let mut conn = pool.get().unwrap();
            let reply = redis::cmd("PING").query::<String>(conn.deref_mut()).unwrap();
            // Alternatively, without deref():
            let reply = redis::cmd("PING").query::<String>(&mut *conn).unwrap();
            assert_eq!("PONG", reply);
        }));
    }

    for h in handles {
        h.join().unwrap();
    }
}

Implementations

impl RedisConnectionManager[src]

pub fn new<T: IntoConnectionInfo>(
    params: T
) -> Result<RedisConnectionManager, RedisError>
[src]

Creates a new RedisConnectionManager.

See redis::Client::open for a to_string of the parameter types.

pub fn with_timeout<T: IntoConnectionInfo>(
    params: T,
    timeout: Option<Duration>
) -> Result<RedisConnectionManager, RedisError>
[src]

Creates a new RedisConnectionManager with connection timeout.

See redis::Client::open for a to_string of the parameter types.

Trait Implementations

impl Debug for RedisConnectionManager[src]

impl ManageConnection for RedisConnectionManager[src]

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, 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.