pub enum AsyncRedisClient {
Cluster(Pool<CustomClusterManager, CustomClusterConnection>),
Single(Pool<CustomSingleManager, CustomSingleConnection>),
}
Expand description
A connection client that can manage either a single Redis instance or a Redis cluster.
This enum provides a unified interface for Redis operations, supporting both single-instance and cluster configurations.
Variants§
Cluster(Pool<CustomClusterManager, CustomClusterConnection>)
Contains a connection pool to a Redis cluster.
Single(Pool<CustomSingleManager, CustomSingleConnection>)
Contains a connection pool to a single Redis instance.
Implementations§
Source§impl AsyncRedisClient
impl AsyncRedisClient
Sourcepub fn cluster<'a>(
servers: impl IntoIterator<Item = &'a str>,
opts: &RedisConfigOptions,
) -> Result<Self, RedisError>
pub fn cluster<'a>( servers: impl IntoIterator<Item = &'a str>, opts: &RedisConfigOptions, ) -> Result<Self, RedisError>
Creates a new connection client for a Redis cluster.
This method initializes a connection client that can communicate with multiple Redis nodes in a cluster configuration. The client is configured with the specified servers and options.
The client uses a custom cluster manager that implements a specific connection recycling strategy, ensuring optimal performance and reliability in cluster environments.
Sourcepub fn single(
server: &str,
opts: &RedisConfigOptions,
) -> Result<Self, RedisError>
pub fn single( server: &str, opts: &RedisConfigOptions, ) -> Result<Self, RedisError>
Creates a new connection client for a single Redis instance.
This method initializes a connection client that communicates with a single Redis server. The client is configured with the specified server URL and options.
The client uses a custom single manager that implements a specific connection recycling strategy, ensuring optimal performance and reliability in single-instance environments.
Sourcepub async fn get_connection(&self) -> Result<AsyncRedisConnection, RedisError>
pub async fn get_connection(&self) -> Result<AsyncRedisConnection, RedisError>
Acquires a connection from the pool.
Returns a new AsyncRedisConnection
that can be used to execute Redis commands.
The connection is automatically returned to the pool when dropped.
Sourcepub fn stats(&self) -> RedisClientStats
pub fn stats(&self) -> RedisClientStats
Returns statistics about the current state of the connection pool.
Provides information about the number of active and idle connections in the pool, which can be useful for monitoring and debugging purposes.
Trait Implementations§
Source§impl Clone for AsyncRedisClient
impl Clone for AsyncRedisClient
Source§fn clone(&self) -> AsyncRedisClient
fn clone(&self) -> AsyncRedisClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more