Struct r2d2_redis::RedisConnectionManager [−][src]
pub struct RedisConnectionManager { /* fields omitted */ }
An r2d2::ConnectionManager
for redis::Client
s.
Example
extern crate r2d2_redis; use std::ops::Deref; 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 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(); } }
Methods
impl RedisConnectionManager
[src]
impl RedisConnectionManager
pub fn new<T: IntoConnectionInfo>(
params: T
) -> Result<RedisConnectionManager, RedisError>
[src]
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
impl Debug for RedisConnectionManager
[src]
impl Debug for RedisConnectionManager
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl ManageConnection for RedisConnectionManager
[src]
impl ManageConnection for RedisConnectionManager
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 connect(&self) -> Result<Connection, Error>
Attempts to create a new connection.
fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>
[src]
fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>
Determines if the connection is still connected to the database. Read more
fn has_broken(&self, _conn: &mut Connection) -> bool
[src]
fn has_broken(&self, _conn: &mut Connection) -> bool
Quickly determines if the connection is no longer usable. Read more
Auto Trait Implementations
impl Send for RedisConnectionManager
impl Send for RedisConnectionManager
impl Sync for RedisConnectionManager
impl Sync for RedisConnectionManager