Skip to main content

AsyncConnection

Struct AsyncConnection 

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

Async TCP-RESP connection. Mirrors [kevy_client::Connection] but drops the mem:// / file:// embedded backends — those are synchronous and have no async story.

Implementations§

Source§

impl AsyncConnection

Source

pub async fn hset( &mut self, key: &[u8], pairs: &[(&[u8], &[u8])], ) -> Result<usize>

HSET key field value [field value ...]. Returns count of fields newly created (overwrites don’t count).

Source

pub async fn hget( &mut self, key: &[u8], field: &[u8], ) -> Result<Option<Vec<u8>>>

HGET key field. None if key or field absent.

Source

pub async fn hdel(&mut self, key: &[u8], fields: &[&[u8]]) -> Result<usize>

HDEL key field [field ...]. Returns count actually removed.

Source

pub async fn hlen(&mut self, key: &[u8]) -> Result<usize>

HLEN key. 0 if absent.

Source

pub async fn hgetall(&mut self, key: &[u8]) -> Result<Vec<Vec<u8>>>

HGETALL key. Flat [f0, v0, f1, v1, ...]. Empty if absent.

Source

pub async fn hkeys(&mut self, key: &[u8]) -> Result<Vec<Vec<u8>>>

HKEYS key. Hash’s field names.

Source

pub async fn hvals(&mut self, key: &[u8]) -> Result<Vec<Vec<u8>>>

HVALS key. Hash’s values.

Source§

impl AsyncConnection

Source

pub async fn lpush(&mut self, key: &[u8], values: &[&[u8]]) -> Result<usize>

LPUSH key value [value ...]. Returns new list length.

Source

pub async fn rpush(&mut self, key: &[u8], values: &[&[u8]]) -> Result<usize>

RPUSH key value [value ...]. Returns new list length.

Source

pub async fn lpop(&mut self, key: &[u8], count: usize) -> Result<Vec<Vec<u8>>>

LPOP key count. Returns up to count head values; empty if absent / drained.

Source

pub async fn rpop(&mut self, key: &[u8], count: usize) -> Result<Vec<Vec<u8>>>

RPOP key count. Symmetric to lpop from the tail.

Source

pub async fn llen(&mut self, key: &[u8]) -> Result<usize>

LLEN key. 0 if absent.

Source

pub async fn lrange( &mut self, key: &[u8], start: i64, stop: i64, ) -> Result<Vec<Vec<u8>>>

LRANGE key start stop. Negative offsets count from tail.

Source§

impl AsyncConnection

Source

pub async fn sadd(&mut self, key: &[u8], members: &[&[u8]]) -> Result<usize>

SADD key member [member ...]. Returns count of newly added.

Source

pub async fn srem(&mut self, key: &[u8], members: &[&[u8]]) -> Result<usize>

SREM key member [member ...]. Returns count actually removed.

Source

pub async fn smembers(&mut self, key: &[u8]) -> Result<Vec<Vec<u8>>>

SMEMBERS key. Implementation-defined order; empty if absent.

Source

pub async fn scard(&mut self, key: &[u8]) -> Result<usize>

SCARD key. 0 if absent.

Source

pub async fn sismember(&mut self, key: &[u8], member: &[u8]) -> Result<bool>

SISMEMBER key member. false if absent.

Source

pub async fn sinter(&mut self, keys: &[&[u8]]) -> Result<Vec<Vec<u8>>>

SINTER key [key ...] — intersection of all sets.

Source

pub async fn sunion(&mut self, keys: &[&[u8]]) -> Result<Vec<Vec<u8>>>

SUNION key [key ...] — union of all sets.

Source

pub async fn sdiff(&mut self, keys: &[&[u8]]) -> Result<Vec<Vec<u8>>>

SDIFF key [key ...] — first set minus the rest.

Source§

impl AsyncConnection

Source

pub async fn set(&mut self, key: &[u8], value: &[u8]) -> Result<()>

SET key value. Unconditional set; returns on +OK.

Source

pub async fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>

GET key. None if absent or expired.

Source

pub async fn del(&mut self, keys: &[&[u8]]) -> Result<usize>

DEL key [key ...]. Returns the count actually removed.

Source

pub async fn exists(&mut self, keys: &[&[u8]]) -> Result<usize>

EXISTS key [key ...]. Count of keys present (a key passed N times counts N if it exists).

Source

pub async fn incr(&mut self, key: &[u8]) -> Result<i64>

INCR key. Returns post-increment value.

Source

pub async fn incr_by(&mut self, key: &[u8], delta: i64) -> Result<i64>

INCRBY key delta. Negative delta = DECRBY.

Source

pub async fn expire(&mut self, key: &[u8], ttl: Duration) -> Result<bool>

PEXPIRE key ttl_ms. Returns whether the key existed and got a TTL set.

Source

pub async fn persist(&mut self, key: &[u8]) -> Result<bool>

PERSIST key. Returns whether a TTL was removed.

Source

pub async fn ttl_ms(&mut self, key: &[u8]) -> Result<i64>

PTTL key. Ms remaining, -2 if no key, -1 if no TTL.

Source

pub async fn type_of(&mut self, key: &[u8]) -> Result<String>

TYPE key. Returns Redis-style type name ("string", "hash", "list", "set", "zset", or "none").

Source

pub async fn dbsize(&mut self) -> Result<usize>

DBSIZE. Total live keys at call time.

Source

pub async fn flushall(&mut self) -> Result<()>

FLUSHALL. WIPES the store. Named flushall not flush to avoid colliding with Write::flush’s sync-to-disk meaning.

Source

pub async fn set_with_ttl( &mut self, key: &[u8], value: &[u8], ttl: Duration, ) -> Result<()>

SET key value PX ttl_ms. Atomic cache-with-expiry.

Source

pub async fn mget(&mut self, keys: &[&[u8]]) -> Result<Vec<Option<Vec<u8>>>>

MGET key [key ...] — one reply per key, in order.

Source

pub async fn mset(&mut self, pairs: &[(&[u8], &[u8])]) -> Result<()>

MSET key value [key value ...] — atomic multi-set.

Source

pub async fn publish(&mut self, channel: &[u8], message: &[u8]) -> Result<usize>

PUBLISH channel message. Returns subscriber-receive count.

Source§

impl AsyncConnection

Source

pub async fn zadd( &mut self, key: &[u8], pairs: &[(f64, &[u8])], ) -> Result<usize>

ZADD key score member [score member ...]. Returns count of newly added (overwrites don’t count).

Source

pub async fn zrem(&mut self, key: &[u8], members: &[&[u8]]) -> Result<usize>

ZREM key member [member ...]. Returns count actually removed.

Source

pub async fn zscore(&mut self, key: &[u8], member: &[u8]) -> Result<Option<f64>>

ZSCORE key member. None if absent.

Source

pub async fn zcard(&mut self, key: &[u8]) -> Result<usize>

ZCARD key. 0 if absent.

Source

pub async fn zrange( &mut self, key: &[u8], start: i64, stop: i64, ) -> Result<Vec<Vec<u8>>>

ZRANGE key start stop. Ascending-score order; negative indices count from the tail.

Source§

impl AsyncConnection

Source

pub async fn open(url: &str) -> Result<Self>

Open a connection from a URL. Accepts kevy://, redis://, tcp:// — see crate::url::parse_url for the full grammar.

If the URL carries a /N db index (only kevy:// and redis://), an initial SELECT N round-trip runs before returning.

Source

pub fn from_transport(transport: TcpStream) -> Self

Direct constructor — useful when the caller wants to manage transport setup itself (cluster client, custom socket opts).

Source

pub async fn ping(&mut self) -> Result<()>

PING. Returns Ok(()) on +PONG.

Source

pub fn codec_mut(&mut self) -> &mut AsyncRespCodec<TcpStream>

Borrow the underlying codec — exposed so pipeline + subscriber adapters built in later tasks (T4.11/T4.14) can share the connection state machine.

Source§

impl AsyncConnection

Source

pub fn pipeline(&mut self) -> Pipeline

Open a Pipeline builder bound to this connection. Chain command-queue methods on the returned Pipeline then call .run(&mut conn).await.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.