pub struct Options {
pub max_attempts: Option<u32>,
pub max_redirections: Option<u32>,
pub timeout: Option<Duration>,
pub cluster_node: Option<Server>,
pub cluster_hash: Option<ClusterHash>,
pub no_backpressure: bool,
pub fail_fast: bool,
pub caching: Option<bool>,
}Expand description
Options to configure or overwrite for individual commands.
Fields left as None will use the value from the corresponding client or global config option.
async fn example() -> Result<(), RedisError> {
let options = Options {
max_attempts: Some(10),
max_redirections: Some(2),
..Default::default()
};
let client = RedisClient::default();
client.init().await?;
let _: () = client.with_options(&options).get("foo").await?;
Ok(())
}See WithOptions for more information.
Fields§
§max_attempts: Option<u32>Set the max number of write attempts for a command.
max_redirections: Option<u32>Set the max number of cluster redirections to follow for a command.
timeout: Option<Duration>Set the timeout duration for a command.
This interface is more* cancellation-safe than a simple timeout call.
* But it’s not perfect. There’s no reliable mechanism to cancel a command once it has been written to the connection.
cluster_node: Option<Server>The cluster node that should receive the command.
The caller will receive a RedisErrorKind::Cluster error if the provided server does not exist.
The client will still follow redirection errors via this interface. Callers may not notice this, but incorrect server arguments here could result in unnecessary calls to refresh the cached cluster routing table.
cluster_hash: Option<ClusterHash>The cluster hashing policy to use, if applicable.
If cluster_node is also provided it will take precedence over this value.
no_backpressure: boolWhether to skip backpressure checks for a command.
fail_fast: boolWhether the command should fail quickly if the connection is not healthy or available for writes. This always
takes precedence over max_attempts if true.
This can be useful for caching use cases where it’s preferable to fail fast with a fallback query to another storage layer rather than wait for a reconnection delay.
Default: false
caching: Option<bool>i-tracking only.Whether to send CLIENT CACHING yes|no before the command.
Implementations§
Trait Implementations§
impl Eq for Options
impl StructuralPartialEq for Options
Auto Trait Implementations§
impl !Freeze for Options
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnwindSafe for Options
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
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)
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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>
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>
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