pub struct ConnectionPool { /* private fields */ }Expand description
A connection pool. Clones are cheap and is the expected way to send the pool around your application.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub async fn create(
address: String,
password: Option<&str>,
connection_count: usize,
) -> Result<Self>
pub async fn create( address: String, password: Option<&str>, connection_count: usize, ) -> Result<Self>
Create a new connection pool for address, with connection_count connections. All connections
are created in this function, and depending on the amount of connections desired, can therefore
take some time to complete. By default, connections will be created with the name darkredis-n,
where n represents the connection number.
§Panics
Will panic if the number of connections is equal to zero.
Sourcepub async fn create_with_name(
name: &str,
address: String,
password: Option<&str>,
connection_count: usize,
) -> Result<Self>
pub async fn create_with_name( name: &str, address: String, password: Option<&str>, connection_count: usize, ) -> Result<Self>
Create a connection pool, but name each connection by name. Useful if you are running multiple services on a single Redis instance.
§Panics
Will panic if the number of connections is equal to zero.
Sourcepub async fn get(&self) -> MutexGuard<'_, Connection>
pub async fn get(&self) -> MutexGuard<'_, Connection>
Get an available connection from the pool, or wait for one to become available if none are available.
Trait Implementations§
Source§impl Clone for ConnectionPool
impl Clone for ConnectionPool
Source§fn clone(&self) -> ConnectionPool
fn clone(&self) -> ConnectionPool
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more