pub struct RedisPool { /* private fields */ }
Implementations§
Source§impl RedisPool
impl RedisPool
Sourcepub fn max_connections(&mut self, size: u32) -> &mut Self
pub fn max_connections(&mut self, size: u32) -> &mut Self
Examples found in repository?
More examples
examples/read_from_stream.rs (line 14)
9async fn main() -> Result<(), Box<dyn std::error::Error>> {
10 let mut pool = RedisPool::from_str("localhost:6379").unwrap();
11 // Or from SocketAddr
12 // let mut pool = RedisPool::from(SocketAddr::from(([127, 0, 0, 1], 6379)));
13
14 let _ = pool.max_connections(10).establish_pool().await?;
15
16 let redis_connection: Rc<RefCell<RedisConnection>> = pool.send_command("SET foo bar").await?;
17
18 let mut redis_connection_guard = redis_connection.borrow_mut();
19
20 let mut buffer = [0; 1024];
21
22 redis_connection_guard.stream.read(&mut buffer).await?;
23
24 println!("Response: {}", String::from_utf8_lossy(&buffer)); // Response: +OK
25
26 let redis_connection: Rc<RefCell<RedisConnection>> = pool.send_command("PING").await?;
27
28 let mut redis_connection_guard = redis_connection.borrow_mut();
29
30 let mut buffer = [0; 1024];
31
32 redis_connection_guard.stream.read(&mut buffer).await?;
33
34 println!("Response: {}", String::from_utf8_lossy(&buffer)); // Response: +PONG
35
36 Ok(())
37}
Sourcepub async fn establish_pool(&mut self) -> Result<(), RedisError>
pub async fn establish_pool(&mut self) -> Result<(), RedisError>
Examples found in repository?
More examples
examples/read_from_stream.rs (line 14)
9async fn main() -> Result<(), Box<dyn std::error::Error>> {
10 let mut pool = RedisPool::from_str("localhost:6379").unwrap();
11 // Or from SocketAddr
12 // let mut pool = RedisPool::from(SocketAddr::from(([127, 0, 0, 1], 6379)));
13
14 let _ = pool.max_connections(10).establish_pool().await?;
15
16 let redis_connection: Rc<RefCell<RedisConnection>> = pool.send_command("SET foo bar").await?;
17
18 let mut redis_connection_guard = redis_connection.borrow_mut();
19
20 let mut buffer = [0; 1024];
21
22 redis_connection_guard.stream.read(&mut buffer).await?;
23
24 println!("Response: {}", String::from_utf8_lossy(&buffer)); // Response: +OK
25
26 let redis_connection: Rc<RefCell<RedisConnection>> = pool.send_command("PING").await?;
27
28 let mut redis_connection_guard = redis_connection.borrow_mut();
29
30 let mut buffer = [0; 1024];
31
32 redis_connection_guard.stream.read(&mut buffer).await?;
33
34 println!("Response: {}", String::from_utf8_lossy(&buffer)); // Response: +PONG
35
36 Ok(())
37}
Sourcepub async fn send_command(
&mut self,
command: &str,
) -> Result<Rc<RefCell<RedisConnection>>, RedisError>
pub async fn send_command( &mut self, command: &str, ) -> Result<Rc<RefCell<RedisConnection>>, RedisError>
Examples found in repository?
More examples
examples/read_from_stream.rs (line 16)
9async fn main() -> Result<(), Box<dyn std::error::Error>> {
10 let mut pool = RedisPool::from_str("localhost:6379").unwrap();
11 // Or from SocketAddr
12 // let mut pool = RedisPool::from(SocketAddr::from(([127, 0, 0, 1], 6379)));
13
14 let _ = pool.max_connections(10).establish_pool().await?;
15
16 let redis_connection: Rc<RefCell<RedisConnection>> = pool.send_command("SET foo bar").await?;
17
18 let mut redis_connection_guard = redis_connection.borrow_mut();
19
20 let mut buffer = [0; 1024];
21
22 redis_connection_guard.stream.read(&mut buffer).await?;
23
24 println!("Response: {}", String::from_utf8_lossy(&buffer)); // Response: +OK
25
26 let redis_connection: Rc<RefCell<RedisConnection>> = pool.send_command("PING").await?;
27
28 let mut redis_connection_guard = redis_connection.borrow_mut();
29
30 let mut buffer = [0; 1024];
31
32 redis_connection_guard.stream.read(&mut buffer).await?;
33
34 println!("Response: {}", String::from_utf8_lossy(&buffer)); // Response: +PONG
35
36 Ok(())
37}
Trait Implementations§
Source§impl From<SocketAddr> for RedisPool
impl From<SocketAddr> for RedisPool
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for RedisPool
impl !RefUnwindSafe for RedisPool
impl !Send for RedisPool
impl !Sync for RedisPool
impl Unpin for RedisPool
impl !UnwindSafe for RedisPool
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