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
impl RemoteCacheClient
Sourcepub fn new(base_url: &str) -> Self
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.
Sourcepub fn set(
&self,
key: &str,
value: &str,
ttl: Option<u64>,
) -> Result<(), String>
pub fn set( &self, key: &str, value: &str, ttl: Option<u64>, ) -> Result<(), String>
SET key value [EX seconds]
Sourcepub fn setnx(
&self,
key: &str,
value: &str,
ttl: Option<u64>,
) -> Result<bool, String>
pub fn setnx( &self, key: &str, value: &str, ttl: Option<u64>, ) -> Result<bool, String>
SETNX key value [EX seconds]
Sourcepub fn getset(&self, key: &str, value: &str) -> Result<Option<String>, String>
pub fn getset(&self, key: &str, value: &str) -> Result<Option<String>, String>
GETSET key value
Sourcepub fn lrange(
&self,
key: &str,
start: i64,
stop: i64,
) -> Result<Vec<String>, String>
pub fn lrange( &self, key: &str, start: i64, stop: i64, ) -> Result<Vec<String>, String>
LRANGE key start stop
Sourcepub fn hset(&self, key: &str, field: &str, value: &str) -> Result<(), String>
pub fn hset(&self, key: &str, field: &str, value: &str) -> Result<(), String>
HSET key field value
Sourcepub fn hincrby(
&self,
key: &str,
field: &str,
amount: i64,
) -> Result<i64, String>
pub fn hincrby( &self, key: &str, field: &str, amount: i64, ) -> Result<i64, String>
HINCRBY key field amount
Sourcepub fn zadd(&self, key: &str, score: f64, member: &str) -> Result<(), String>
pub fn zadd(&self, key: &str, score: f64, member: &str) -> Result<(), String>
ZADD key score member
Sourcepub fn zrange(
&self,
key: &str,
start: usize,
stop: usize,
) -> Result<Vec<(String, f64)>, String>
pub fn zrange( &self, key: &str, start: usize, stop: usize, ) -> Result<Vec<(String, f64)>, String>
ZRANGE key start stop
Sourcepub fn publish(&self, channel: &str, message: &str) -> Result<usize, String>
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.
Sourcepub fn channels(&self) -> Result<Vec<(String, usize)>, String>
pub fn channels(&self) -> Result<Vec<(String, usize)>, String>
List channels with subscriber counts.
Auto Trait Implementations§
impl Freeze for RemoteCacheClient
impl RefUnwindSafe for RemoteCacheClient
impl Send for RemoteCacheClient
impl Sync for RemoteCacheClient
impl Unpin for RemoteCacheClient
impl UnsafeUnpin for RemoteCacheClient
impl UnwindSafe for RemoteCacheClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more