Skip to main content

ValkeyConnector

Struct ValkeyConnector 

Source
pub struct ValkeyConnector { /* private fields */ }
Expand description

Reconnecting, multiplexed Valkey database connector.

The connector is cheap to clone and shares one bounded connection manager. Its generic query methods discard driver diagnostics and expose only stable kit errors, while typed convenience methods provide common cache, lease, and counter behavior.

Implementations§

Source§

impl ValkeyConnector

Source

pub async fn connect(config: &ValkeyConfig) -> ValkeyResult<Self>

Establishes and authenticates the initial connection.

Source

pub async fn health_check(&self) -> ValkeyResult<()>

Verifies that the server accepts commands on the current connection.

Source

pub async fn health_report(&self) -> ValkeyResult<ValkeyHealthReport>

Verifies readiness and returns bounded, non-sensitive connector state.

Source

pub async fn query<T>(&self, command: &Cmd) -> ValkeyResult<T>
where T: FromRedisValue,

Executes an app-owned command through the bounded managed connection.

Command names must be fixed by application code. Untrusted data belongs only in encoded command arguments, never in the command name. Apps that use keys should call Self::namespaced_key so deployments retain namespace isolation. Raw driver diagnostics are discarded at this boundary and never become application errors or logs.

Source

pub async fn query_pipeline<T>(&self, pipeline: &Pipeline) -> ValkeyResult<T>
where T: FromRedisValue,

Executes an app-owned pipeline through the bounded managed connection.

A pipeline is not atomic unless the caller explicitly enables transaction mode on the pipeline. The same namespace and untrusted-input requirements as Self::query apply.

Source

pub async fn get(&self, key: &ValkeyKey) -> ValkeyResult<Option<ValkeyValue>>

Reads a value, returning None when the key is absent or expired.

Source

pub async fn set_with_ttl( &self, key: &ValkeyKey, value: &ValkeyValue, ttl: ValkeyTimeToLive, ) -> ValkeyResult<()>

Stores a value with a mandatory expiration.

Source

pub async fn set_if_absent_with_ttl( &self, key: &ValkeyKey, value: &ValkeyValue, ttl: ValkeyTimeToLive, ) -> ValkeyResult<bool>

Acquires a lease only when its key is absent, always with an expiration.

Source

pub async fn delete(&self, key: &ValkeyKey) -> ValkeyResult<bool>

Deletes a key and reports whether it existed.

Source

pub async fn release_lease( &self, key: &ValkeyKey, lease_token: &ValkeyValue, ) -> ValkeyResult<bool>

Atomically releases a lease only when the stored token still matches.

Source

pub async fn increment_with_ttl( &self, key: &ValkeyKey, increment: NonZeroU64, ttl: ValkeyTimeToLive, ) -> ValkeyResult<u64>

Atomically increments a counter and sets its TTL only when first created.

Source

pub fn namespaced_key( &self, key: &ValkeyKey, ) -> ValkeyResult<Zeroizing<Vec<u8>>>

Builds the deployment namespace plus a validated application key.

The returned buffer clears its allocation on drop and can be passed directly to a Valkey command as binary data.

Trait Implementations§

Source§

impl Clone for ValkeyConnector

Source§

fn clone(&self) -> ValkeyConnector

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 ValkeyConnector

Source§

fn fmt(&self, formatter: &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<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, 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> 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.