Skip to main content

RemoteCacheClient

Struct RemoteCacheClient 

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

A client that connects to a remote pylon cache server.

Uses raw HTTP/1.1 over TCP to avoid pulling in heavy HTTP client dependencies. Each request opens a new connection (Connection: close). This keeps the client simple and dependency-free.

Implementations§

Source§

impl RemoteCacheClient

Source

pub fn new(base_url: &str) -> Self

Create a new client pointing at the given base URL.

The URL should be of the form http://host:port. Any trailing slash or path component is stripped.

Source

pub fn set( &self, key: &str, value: &str, ttl: Option<u64>, ) -> Result<(), String>

SET key value [EX seconds]

Source

pub fn get_key(&self, key: &str) -> Result<Option<String>, String>

GET key

Source

pub fn del(&self, key: &str) -> Result<bool, String>

DEL key

Source

pub fn exists(&self, key: &str) -> Result<bool, String>

EXISTS key

Source

pub fn incr(&self, key: &str) -> Result<i64, String>

INCR key

Source

pub fn decr(&self, key: &str) -> Result<i64, String>

DECR key

Source

pub fn incrby(&self, key: &str, amount: i64) -> Result<i64, String>

INCRBY key amount

Source

pub fn setnx( &self, key: &str, value: &str, ttl: Option<u64>, ) -> Result<bool, String>

SETNX key value [EX seconds]

Source

pub fn getset(&self, key: &str, value: &str) -> Result<Option<String>, String>

GETSET key value

Source

pub fn lpush(&self, key: &str, value: &str) -> Result<usize, String>

LPUSH key value

Source

pub fn rpush(&self, key: &str, value: &str) -> Result<usize, String>

RPUSH key value

Source

pub fn lpop(&self, key: &str) -> Result<Option<String>, String>

LPOP key

Source

pub fn rpop(&self, key: &str) -> Result<Option<String>, String>

RPOP key

Source

pub fn lrange( &self, key: &str, start: i64, stop: i64, ) -> Result<Vec<String>, String>

LRANGE key start stop

Source

pub fn llen(&self, key: &str) -> Result<usize, String>

LLEN key

Source

pub fn sadd(&self, key: &str, member: &str) -> Result<bool, String>

SADD key member

Source

pub fn srem(&self, key: &str, member: &str) -> Result<bool, String>

SREM key member

Source

pub fn smembers(&self, key: &str) -> Result<Vec<String>, String>

SMEMBERS key

Source

pub fn sismember(&self, key: &str, member: &str) -> Result<bool, String>

SISMEMBER key member

Source

pub fn scard(&self, key: &str) -> Result<usize, String>

SCARD key

Source

pub fn hset(&self, key: &str, field: &str, value: &str) -> Result<(), String>

HSET key field value

Source

pub fn hget(&self, key: &str, field: &str) -> Result<Option<String>, String>

HGET key field

Source

pub fn hdel(&self, key: &str, field: &str) -> Result<bool, String>

HDEL key field

Source

pub fn hgetall(&self, key: &str) -> Result<HashMap<String, String>, String>

HGETALL key

Source

pub fn hexists(&self, key: &str, field: &str) -> Result<bool, String>

HEXISTS key field

Source

pub fn hlen(&self, key: &str) -> Result<usize, String>

HLEN key

Source

pub fn hkeys(&self, key: &str) -> Result<Vec<String>, String>

HKEYS key

Source

pub fn hincrby( &self, key: &str, field: &str, amount: i64, ) -> Result<i64, String>

HINCRBY key field amount

Source

pub fn zadd(&self, key: &str, score: f64, member: &str) -> Result<(), String>

ZADD key score member

Source

pub fn zrem(&self, key: &str, member: &str) -> Result<bool, String>

ZREM key member

Source

pub fn zscore(&self, key: &str, member: &str) -> Result<Option<f64>, String>

ZSCORE key member

Source

pub fn zrank(&self, key: &str, member: &str) -> Result<Option<usize>, String>

ZRANK key member

Source

pub fn zrange( &self, key: &str, start: usize, stop: usize, ) -> Result<Vec<(String, f64)>, String>

ZRANGE key start stop

Source

pub fn zcard(&self, key: &str) -> Result<usize, String>

ZCARD key

Source

pub fn keys(&self, pattern: &str) -> Result<Vec<String>, String>

KEYS pattern

Source

pub fn ttl(&self, key: &str) -> Result<Option<u64>, String>

TTL key

Source

pub fn expire(&self, key: &str, seconds: u64) -> Result<bool, String>

EXPIRE key seconds

Source

pub fn persist(&self, key: &str) -> Result<bool, String>

PERSIST key

Source

pub fn key_type(&self, key: &str) -> Result<String, String>

TYPE key

Source

pub fn dbsize(&self) -> Result<usize, String>

DBSIZE

Source

pub fn flushall(&self) -> Result<(), String>

FLUSHALL

Source

pub fn info(&self) -> Result<Value, String>

INFO

Source

pub fn publish(&self, channel: &str, message: &str) -> Result<usize, String>

Publish a message to a channel on the remote cache server. Returns the number of subscribers notified.

Source

pub fn channels(&self) -> Result<Vec<(String, usize)>, String>

List channels with subscriber counts.

Source

pub fn history(&self, channel: &str, limit: usize) -> Result<Vec<Value>, String>

Get message history for a channel.

Source

pub fn health(&self) -> Result<Value, String>

Health check – returns the server’s health response.

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V