[−][src]Struct r2d2_redis::RedisConnectionManager
An r2d2::ConnectionManager
for redis::Client
s.
Example
extern crate r2d2_redis; use std::ops::DerefMut; use std::thread; use r2d2_redis::{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(); } }
Methods
impl RedisConnectionManager
[src]
pub fn new<T: IntoConnectionInfo>(
params: T
) -> Result<RedisConnectionManager, RedisError>
[src]
params: T
) -> Result<RedisConnectionManager, RedisError>
Creates a new RedisConnectionManager
.
See redis::Client::open
for a description 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 = Error
The error type returned by Connection
s.
fn connect(&self) -> Result<Connection, Error>
[src]
fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>
[src]
fn has_broken(&self, conn: &mut Connection) -> bool
[src]
Auto Trait Implementations
impl Send for RedisConnectionManager
impl Sync for RedisConnectionManager
impl Unpin for RedisConnectionManager
impl UnwindSafe for RedisConnectionManager
impl RefUnwindSafe for RedisConnectionManager
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,