pub struct RedisConfig {
pub host: String,
pub port: u16,
pub username: String,
pub password: String,
pub database: u32,
pub max_connections: usize,
pub connect_timeout: Duration,
pub command_timeout: Duration,
pub scheme: String,
}Fields§
§host: String§port: u16§username: StringRedis 6 ACL username. Empty means the legacy single-password mode.
password: String§database: u32The numbered database SELECTed after connecting.
max_connections: usizeConnections the pool will open at once.
connect_timeout: Duration§command_timeout: DurationHow long one command may take before the connection is given up on.
scheme: Stringredis or valkey — whichever the URL said.
Kept so every message about the connection echoes the name the operator used. A Valkey deployment told it “cannot connect to redis://…” goes looking for a Redis configuration that does not exist.
Implementations§
Source§impl RedisConfig
impl RedisConfig
Sourcepub fn from_url(url: &str) -> Result<Self>
pub fn from_url(url: &str) -> Result<Self>
Parse redis://[[user]:password@]host[:port][/db], or the same with
valkey://.
Valkey is the same wire protocol. It is the Linux Foundation fork of
Redis 7.2, speaks RESP unchanged, and this client’s whole test suite
passes against Valkey 8 as it stands. What a Valkey deployment needs is
not a second client but a client that answers to the name: its own
tooling writes valkey://, and an operator who pastes that URL should
not be told it is not a Redis URL.
The password-only form redis://:secret@host is the one almost every
deployment uses, so it is handled first-class rather than as a special
case of a username.
Sourcepub fn from_app_config(config: &Config) -> Result<Self>
pub fn from_app_config(config: &Config) -> Result<Self>
Read from the application config, falling back to REDIS_URL and then
VALKEY_URL.
Both names, because a Valkey deployment’s own documentation and tooling use the second, and an operator who sets the variable their platform told them to set should find it read.
pub fn address(&self) -> String
Sourcepub fn redacted_url(&self) -> String
pub fn redacted_url(&self) -> String
The URL with the password removed, for logs and error messages.
Every message this crate produces about a connection uses this, so a stack trace on a shared screen never leaks a credential.
Trait Implementations§
Source§impl Clone for RedisConfig
impl Clone for RedisConfig
Source§fn clone(&self) -> RedisConfig
fn clone(&self) -> RedisConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more