Struct RedisConnectionManager

Source
pub struct RedisConnectionManager { /* private fields */ }
Expand description

An r2d2::ConnectionManager for redis::Clients.

§Example

extern crate r2d2;
extern crate r2d2_redis;
extern crate redis;

use std::default::Default;
use std::ops::Deref;
use std::thread;

use r2d2_redis::RedisConnectionManager;

fn main() {
    let config = Default::default();
    let manager = RedisConnectionManager::new("redis://localhost").unwrap();
    let pool = r2d2::Pool::new(config, manager).unwrap();

    let mut handles = vec![];

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

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

Implementations§

Source§

impl RedisConnectionManager

Source

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

Creates a new RedisConnectionManager.

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

Trait Implementations§

Source§

impl Debug for RedisConnectionManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ManageConnection for RedisConnectionManager

Source§

type Connection = Connection

The connection type this manager deals with.
Source§

type Error = Error

The error type returned by Connections.
Source§

fn connect(&self) -> Result<Connection, Error>

Attempts to create a new connection.
Source§

fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>

Determines if the connection is still connected to the database. Read more
Source§

fn has_broken(&self, _conn: &mut Connection) -> bool

Quickly determines if the connection is no longer usable. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.