Skip to main content

ClusterClient

Struct ClusterClient 

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

One open connection per distinct shard node, with a slot → shard index so a single-key command goes straight to its owner.

Implementations§

Source§

impl ClusterClient

Source

pub fn connect(host: &str, port: u16) -> KevyResult<Self>

Connect via a seed node, discover the topology (CLUSTER SLOTS), and open one connection per shard.

Source

pub fn request_keyed( &mut self, key: &[u8], args: &[Vec<u8>], ) -> KevyResult<Reply>

Route a single-key command (args) to the shard owning key.

Source

pub fn request_unkeyed(&mut self, args: &[Vec<u8>]) -> KevyResult<Reply>

A keyless command (PING / etc.) — answered identically by any shard, so send it to the first.

Source

pub fn shard_count(&self) -> usize

Number of distinct shard nodes.

Source§

impl ClusterClient

Source

pub fn ping(&mut self) -> KevyResult<()>

PING — answered by any shard.

Source

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

PUBLISH channel message — returns the number of subscribers reached. kevy’s pub/sub is process-global (delivered to subscribers on every core), so a cluster PUBLISH goes to any one shard.

Source

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

SET key value.

Source

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

SET key value PX ttl_ms — value with an expiry.

Source

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

GET key. None if absent or expired.

Source

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

INCR key. Returns the post-increment value.

Source

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

INCRBY key delta.

Source

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

PEXPIRE key ttl_ms. Whether the key existed and got a TTL.

Source

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

PERSIST key. Whether a TTL was removed.

Source

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

PTTL key. ms remaining, -2 no key, -1 no TTL.

Source

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

DEL key [key ...] — routed per key (each to its owner) and summed, so keys spanning shards work without a same-slot constraint.

Source

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

EXISTS key [key ...] — routed per key and summed (a repeated key counts each time, matching Redis).

Source

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

DBSIZE — the cluster-wide total. kevy answers DBSIZE by fanning out across shards internally (Route::Dbsize), so a single shard already reports the whole-cluster count; no client-side summing.

Source

pub fn flushall(&mut self) -> KevyResult<()>

FLUSHALL — clears every shard. kevy fans FLUSHALL out internally (Route::Flush), so one call wipes the whole cluster.

Source§

impl ClusterClient

Source

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

HSET key field value [field value ...] — count of newly added fields.

Source

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

HGET key field. None when key or field absent.

Source

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

HDEL key field [field ...] — count of fields removed.

Source

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

HLEN key.

Source

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

HGETALL key — flat [f0, v0, f1, v1, …].

Source

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

HKEYS key.

Source

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

HVALS key.

Source

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

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

Source

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

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

Source

pub fn lpop(&mut self, key: &[u8], n: usize) -> KevyResult<Vec<Vec<u8>>>

LPOP key count.

Source

pub fn rpop(&mut self, key: &[u8], n: usize) -> KevyResult<Vec<Vec<u8>>>

RPOP key count.

Source

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

LLEN key.

Source

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

LRANGE key start stop (Redis-style negative indices).

Source

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

SADD key member [member ...] — count newly added.

Source

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

SREM key member [member ...] — count removed.

Source

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

SMEMBERS key.

Source

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

SCARD key.

Source

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

SISMEMBER key member.

Source

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

SINTER key [key ...] — all keys must share a slot (route by the first).

Source

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

SUNION key [key ...] — same-slot.

Source

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

SDIFF key [key ...] — same-slot.

Source

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

ZADD key score member [score member ...] — count newly added.

Source

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

ZREM key member [member ...] — count removed.

Source

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

ZSCORE key member. None if absent.

Source

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

ZCARD key.

Source

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

ZRANGE key start stop (ascending score; negative indices from tail).

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 = !

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.