Connecting to Redis

The r2d2 connection to Redis looks similar to other databases:

let addr = matches.value_of("database")
.unwrap_or("redis://127.0.0.1/");
let manager = RedisConnectionManager::new(addr)?;
let pool = r2d2::Pool::builder().build(manager)?;
let conn = pool.get()?;

We get the address from the --database argument, but if it isn't set, we will use the default value, redis://127.0.0.1/. After that, we will create a new RedisConnectionManager instance and pass it to the Pool::new method.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.74.66