pub enum RedisPool {
Cluster(Pool<ClusterClient>, RedisConfigOptions),
MultiWrite {
primary: Box<RedisPool>,
secondaries: Vec<RedisPool>,
},
Single(Pool<Client>, RedisConfigOptions),
}
Expand description
Abstraction over cluster vs non-cluster mode.
Even just writing a method that takes a command and executes it doesn’t really work because
there’s both Cmd
and ScriptInvocation
to take care of, and both have sync vs async
APIs.
Basically don’t waste your time here, if you want to abstract over this, consider upstreaming to the redis crate.
Variants§
Cluster(Pool<ClusterClient>, RedisConfigOptions)
Pool that is connected to a Redis cluster.
MultiWrite
Multiple pools that are used for multi-write.
Fields
Single(Pool<Client>, RedisConfigOptions)
Pool that is connected to a single Redis instance.
Implementations§
source§impl RedisPool
impl RedisPool
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 RedisPool
in cluster configuration.
sourcepub fn multi_write(
primary: RedisPool,
secondaries: Vec<RedisPool>,
) -> Result<Self, RedisError>
pub fn multi_write( primary: RedisPool, secondaries: Vec<RedisPool>, ) -> Result<Self, RedisError>
Creates a RedisPool
in multi write configuration.
sourcepub fn single(
server: &str,
opts: RedisConfigOptions,
) -> Result<Self, RedisError>
pub fn single( server: &str, opts: RedisConfigOptions, ) -> Result<Self, RedisError>
Creates a RedisPool
in single-node configuration.
sourcepub fn client(&self) -> Result<PooledClient, RedisError>
pub fn client(&self) -> Result<PooledClient, RedisError>
Returns a pooled connection to a client.
Trait Implementations§
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
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