January 2019
Intermediate to advanced
520 pages
14h 32m
English
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.
Read now
Unlock full access