Skip to main content

CacheConfig

Struct CacheConfig 

Source
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

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
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.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more