pub struct CacheConfig {
pub url: String,
pub pool_size: usize,
pub ca_cert_path: Option<String>,
pub password: Option<String>,
}Expand description
Debug is implemented by hand (see below) rather than derived, because
both url and password can carry the AUTH secret — a derived Debug
would print it in the clear via any {:?} or tracing::debug!(?config),
defeating the entire point of keeping the password out of the logs.
Do not replace it with #[derive(Debug)].
Fields§
§url: String§pool_size: usize§ca_cert_path: Option<String>Path to a PEM-encoded CA certificate used to verify the server’s TLS
certificate when url uses the rediss:// scheme. Ignored for
plaintext redis:// connections.
password: Option<String>The Valkey/Redis AUTH password, kept out of url entirely.
This is the recommended way to supply a password: url becomes
credential-free (e.g. rediss://host:6379) and never ends up in
logs, error messages, or metrics that capture the connection string.
When set, it takes priority over any credentials embedded in url.
The URL-with-credentials form (redis://:<password>@host:port,
percent-encoded by connect) remains supported for backward
compatibility, but it cannot represent a password containing a raw
? or #: those characters make the URL’s authority/query/fragment
boundary structurally ambiguous no matter how the userinfo is
encoded. A password with ?/# in it must use password /
VALKEY_PASSWORD.
Implementations§
Source§impl CacheConfig
impl CacheConfig
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Reads VALKEY_URL/REDIS_URL, VALKEY_POOL_SIZE, VALKEY_CA_CERT
and VALKEY_PASSWORD from the environment.
VALKEY_PASSWORD is the recommended way to supply a password: set it
and use a credential-free VALKEY_URL (e.g. rediss://host:6379).
The legacy URL-with-credentials form is still read and supported (see
CacheConfig::password for why it can’t handle every password).
Trait Implementations§
Source§impl Clone for CacheConfig
impl Clone for CacheConfig
Source§impl Debug for CacheConfig
Hand-written so the AUTH secret never reaches a log line. password is
reduced to a presence flag (never its value, never its length), and url
is passed through [redact_url] because it can embed credentials.
impl Debug for CacheConfig
Hand-written so the AUTH secret never reaches a log line. password is
reduced to a presence flag (never its value, never its length), and url
is passed through [redact_url] because it can embed credentials.
Auto Trait Implementations§
impl Forget for CacheConfig
impl Freeze for CacheConfig
impl Move for CacheConfig
impl RefUnwindSafe for CacheConfig
impl Send for CacheConfig
impl Sync for CacheConfig
impl Unpin for CacheConfig
impl UnsafeUnpin for CacheConfig
impl UnwindSafe for CacheConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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