pub struct RedisConf<'a> { /* private fields */ }
Implementations§
Source§impl<'a> RedisConf<'a>
impl<'a> RedisConf<'a>
Sourcepub fn builder() -> Self
pub fn builder() -> Self
Examples found in repository?
examples/redis_basic.rs (line 7)
5fn main() {
6 let dsn = "redis://:@127.0.0.1:6379/0";
7 let pool = RedisConf::builder().with_dsn(dsn).init_pool();
8 let mut conn = pool.get().unwrap();
9
10 // 设置单个pool timeout
11 // let mut conn = pool.get_timeout(Duration::from_secs(2)).unwrap();
12 let res: RedisResult<String> = conn.set("my_user", "daheige");
13 if res.is_err() {
14 println!("redis set error:{}", res.err().unwrap().to_string());
15 } else {
16 println!("set success");
17 }
18}
Sourcepub fn with_dsn(self, dsn: &'a str) -> Self
pub fn with_dsn(self, dsn: &'a str) -> Self
Examples found in repository?
examples/redis_basic.rs (line 7)
5fn main() {
6 let dsn = "redis://:@127.0.0.1:6379/0";
7 let pool = RedisConf::builder().with_dsn(dsn).init_pool();
8 let mut conn = pool.get().unwrap();
9
10 // 设置单个pool timeout
11 // let mut conn = pool.get_timeout(Duration::from_secs(2)).unwrap();
12 let res: RedisResult<String> = conn.set("my_user", "daheige");
13 if res.is_err() {
14 println!("redis set error:{}", res.err().unwrap().to_string());
15 } else {
16 println!("set success");
17 }
18}
pub fn with_cluster_nodes(self, nodes: Vec<&'a str>) -> Self
pub fn with_max_size(self, max: u32) -> Self
pub fn with_min_idle(self, min: u32) -> Self
pub fn with_max_lifetime(self, lifetime: Duration) -> Self
pub fn with_idle_timeout(self, timeout: Duration) -> Self
pub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn client(&self) -> RedisResult<Client>
pub fn cluster_client(&self) -> RedisResult<ClusterClient>
Sourcepub fn init_pool(&self) -> Pool<Client>
pub fn init_pool(&self) -> Pool<Client>
Examples found in repository?
examples/redis_basic.rs (line 7)
5fn main() {
6 let dsn = "redis://:@127.0.0.1:6379/0";
7 let pool = RedisConf::builder().with_dsn(dsn).init_pool();
8 let mut conn = pool.get().unwrap();
9
10 // 设置单个pool timeout
11 // let mut conn = pool.get_timeout(Duration::from_secs(2)).unwrap();
12 let res: RedisResult<String> = conn.set("my_user", "daheige");
13 if res.is_err() {
14 println!("redis set error:{}", res.err().unwrap().to_string());
15 } else {
16 println!("set success");
17 }
18}
pub fn init_cluster_pool(&self) -> Pool<ClusterClient>
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for RedisConf<'a>
impl<'a> RefUnwindSafe for RedisConf<'a>
impl<'a> Send for RedisConf<'a>
impl<'a> Sync for RedisConf<'a>
impl<'a> Unpin for RedisConf<'a>
impl<'a> UnwindSafe for RedisConf<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more