pub enum AsyncRedisConnection {
Cluster(ClusterConnection),
Single(ConnectionManager),
}
Expand description
A wrapper Type for async redis connections. Conceptually it’s similar to RedisPool
but async redis does not require a pool since the connections can just be cloned and
are thread safe.
Variants§
Cluster(ClusterConnection)
Variant for [ClusterConnection
].
Single(ConnectionManager)
Variant for [ConnectionManager
] using [redis::aio::MultiplexedConnection
].
Implementations§
source§impl AsyncRedisConnection
impl AsyncRedisConnection
sourcepub async fn cluster<'a>(
servers: impl IntoIterator<Item = &'a str>,
opts: &RedisConfigOptions,
) -> Result<Self, RedisError>
pub async fn cluster<'a>( servers: impl IntoIterator<Item = &'a str>, opts: &RedisConfigOptions, ) -> Result<Self, RedisError>
Creates a AsyncRedisConnection
in cluster mode.
sourcepub async fn single(
server: &str,
opts: &RedisConfigOptions,
) -> Result<Self, RedisError>
pub async fn single( server: &str, opts: &RedisConfigOptions, ) -> Result<Self, RedisError>
Create a AsyncRedisConnection
in single mode.
sourcepub async fn query_async<T: FromRedisValue>(
&self,
cmd: Cmd,
) -> Result<T, RedisError>
pub async fn query_async<T: FromRedisValue>( &self, cmd: Cmd, ) -> Result<T, RedisError>
Runs the given command on redis and returns the result.
sourcepub fn stats(&self) -> Stats
pub fn stats(&self) -> Stats
Return Stats
for AsyncRedisConnection
.
It will always return 0 for idle_connections
and 1 for connections
since we
are re-using the same connection.
Trait Implementations§
source§impl Clone for AsyncRedisConnection
impl Clone for AsyncRedisConnection
source§fn clone(&self) -> AsyncRedisConnection
fn clone(&self) -> AsyncRedisConnection
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for AsyncRedisConnection
impl !RefUnwindSafe for AsyncRedisConnection
impl Send for AsyncRedisConnection
impl Sync for AsyncRedisConnection
impl Unpin for AsyncRedisConnection
impl !UnwindSafe for AsyncRedisConnection
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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