pub struct ClientHashRing(/* private fields */);Implementations§
Source§impl ClientHashRing
impl ClientHashRing
Sourcepub fn new(conns: Vec<Connection>) -> Self
pub fn new(conns: Vec<Connection>) -> Self
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);Sourcepub async fn get(&mut self, key: impl AsRef<[u8]>) -> Result<Option<Item>>
pub async fn get(&mut self, key: impl AsRef<[u8]>) -> Result<Option<Item>>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.set(b"k7", 0, 0, false, b"v7").await?);
assert_eq!(client.get(b"k7").await?.unwrap().key, "k7");Sourcepub async fn gets(&mut self, key: impl AsRef<[u8]>) -> Result<Option<Item>>
pub async fn gets(&mut self, key: impl AsRef<[u8]>) -> Result<Option<Item>>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.set(b"k8", 0, 0, false, b"v8").await?);
assert_eq!(client.gets(b"k8").await?.unwrap().key, "k8");Sourcepub async fn gat(
&mut self,
exptime: i64,
key: impl AsRef<[u8]>,
) -> Result<Option<Item>>
pub async fn gat( &mut self, exptime: i64, key: impl AsRef<[u8]>, ) -> Result<Option<Item>>
§Example
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.set(b"k9", 0, 0, false, b"v9").await?);
let result = client.gat(0, b"k9").await?;
assert_eq!(result.unwrap().key, "k9");Sourcepub async fn gats(
&mut self,
exptime: i64,
key: impl AsRef<[u8]>,
) -> Result<Option<Item>>
pub async fn gats( &mut self, exptime: i64, key: impl AsRef<[u8]>, ) -> Result<Option<Item>>
§Example
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.set(b"k10", 0, 0, false, b"v10").await?);
let result = client.gats(0, b"k10").await?;
assert_eq!(result.unwrap().key, "k10");Sourcepub async fn set(
&mut self,
key: impl AsRef<[u8]>,
flags: u32,
exptime: i64,
noreply: bool,
data_block: impl AsRef<[u8]>,
) -> Result<bool>
pub async fn set( &mut self, key: impl AsRef<[u8]>, flags: u32, exptime: i64, noreply: bool, data_block: impl AsRef<[u8]>, ) -> Result<bool>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.set(b"key", 0, -1, true, b"value").await?);Sourcepub async fn add(
&mut self,
key: impl AsRef<[u8]>,
flags: u32,
exptime: i64,
noreply: bool,
data_block: impl AsRef<[u8]>,
) -> Result<bool>
pub async fn add( &mut self, key: impl AsRef<[u8]>, flags: u32, exptime: i64, noreply: bool, data_block: impl AsRef<[u8]>, ) -> Result<bool>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.add(b"key", 0, -1, true, b"value").await?);Sourcepub async fn replace(
&mut self,
key: impl AsRef<[u8]>,
flags: u32,
exptime: i64,
noreply: bool,
data_block: impl AsRef<[u8]>,
) -> Result<bool>
pub async fn replace( &mut self, key: impl AsRef<[u8]>, flags: u32, exptime: i64, noreply: bool, data_block: impl AsRef<[u8]>, ) -> Result<bool>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.replace(b"key", 0, -1, true, b"value").await?);Sourcepub async fn append(
&mut self,
key: impl AsRef<[u8]>,
flags: u32,
exptime: i64,
noreply: bool,
data_block: impl AsRef<[u8]>,
) -> Result<bool>
pub async fn append( &mut self, key: impl AsRef<[u8]>, flags: u32, exptime: i64, noreply: bool, data_block: impl AsRef<[u8]>, ) -> Result<bool>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.append(b"key", 0, -1, true, b"value").await?);Sourcepub async fn prepend(
&mut self,
key: impl AsRef<[u8]>,
flags: u32,
exptime: i64,
noreply: bool,
data_block: impl AsRef<[u8]>,
) -> Result<bool>
pub async fn prepend( &mut self, key: impl AsRef<[u8]>, flags: u32, exptime: i64, noreply: bool, data_block: impl AsRef<[u8]>, ) -> Result<bool>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.prepend(b"key", 0, -1, true, b"value").await?);Sourcepub async fn cas(
&mut self,
key: impl AsRef<[u8]>,
flags: u32,
exptime: i64,
cas_unique: u64,
noreply: bool,
data_block: impl AsRef<[u8]>,
) -> Result<bool>
pub async fn cas( &mut self, key: impl AsRef<[u8]>, flags: u32, exptime: i64, cas_unique: u64, noreply: bool, data_block: impl AsRef<[u8]>, ) -> Result<bool>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.cas(b"key", 0, -1, 0, true, b"value").await?);Sourcepub async fn delete(
&mut self,
key: impl AsRef<[u8]>,
noreply: bool,
) -> Result<bool>
pub async fn delete( &mut self, key: impl AsRef<[u8]>, noreply: bool, ) -> Result<bool>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.delete(b"key", true).await?);Sourcepub async fn incr(
&mut self,
key: impl AsRef<[u8]>,
value: u64,
noreply: bool,
) -> Result<Option<u64>>
pub async fn incr( &mut self, key: impl AsRef<[u8]>, value: u64, noreply: bool, ) -> Result<Option<u64>>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.incr(b"key", 1, true).await?.is_none());Sourcepub async fn decr(
&mut self,
key: impl AsRef<[u8]>,
value: u64,
noreply: bool,
) -> Result<Option<u64>>
pub async fn decr( &mut self, key: impl AsRef<[u8]>, value: u64, noreply: bool, ) -> Result<Option<u64>>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.decr(b"key", 1, true).await?.is_none());Sourcepub async fn touch(
&mut self,
key: impl AsRef<[u8]>,
exptime: i64,
noreply: bool,
) -> Result<bool>
pub async fn touch( &mut self, key: impl AsRef<[u8]>, exptime: i64, noreply: bool, ) -> Result<bool>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.touch(b"key", -1, true).await?);Sourcepub async fn me(&mut self, key: impl AsRef<[u8]>) -> Result<Option<String>>
pub async fn me(&mut self, key: impl AsRef<[u8]>) -> Result<Option<String>>
§Example
use mcmc_rs::{ClientHashRing, Connection};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
assert!(client.set(b"k11", 0, 0, false, b"v11").await?);
assert!(client.me(b"k11").await?.is_some());Sourcepub async fn mg(
&mut self,
key: impl AsRef<[u8]>,
flags: &[MgFlag],
) -> Result<MgItem>
pub async fn mg( &mut self, key: impl AsRef<[u8]>, flags: &[MgFlag], ) -> Result<MgItem>
§Example
use mcmc_rs::{ClientHashRing, Connection, MgFlag, MgItem};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
let result = client
.mg(
b"44OG44K544OI",
&[
MgFlag::Base64Key,
MgFlag::ReturnCas,
MgFlag::ReturnFlags,
MgFlag::ReturnHit,
MgFlag::ReturnKey,
MgFlag::ReturnLastAccess,
MgFlag::Opaque("opaque".to_string()),
MgFlag::ReturnSize,
MgFlag::ReturnTtl,
MgFlag::UnBump,
MgFlag::ReturnValue,
MgFlag::NewCas(0),
MgFlag::Autovivify(-1),
MgFlag::RecacheTtl(-1),
MgFlag::UpdateTtl(-1),
],
)
.await?;
assert_eq!(
result,
MgItem {
success: true,
base64_key: false,
cas: Some(0),
flags: Some(0),
hit: Some(0),
key: Some("テスト".to_string()),
last_access_ttl: Some(0),
opaque: Some("opaque".to_string()),
size: Some(0),
ttl: Some(-1),
data_block: Some(vec![]),
already_win: false,
won_recache: true,
stale: false,
}
);Sourcepub async fn ms(
&mut self,
key: impl AsRef<[u8]>,
flags: &[MsFlag],
data_block: impl AsRef<[u8]>,
) -> Result<MsItem>
pub async fn ms( &mut self, key: impl AsRef<[u8]>, flags: &[MsFlag], data_block: impl AsRef<[u8]>, ) -> Result<MsItem>
§Example
use mcmc_rs::{ClientHashRing, Connection, MsFlag, MsItem, MsMode};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
let result = client
.ms(
b"44OG44K544OI",
&[
MsFlag::Base64Key,
MsFlag::ReturnCas,
MsFlag::CompareCas(0),
MsFlag::NewCas(0),
MsFlag::SetFlags(0),
MsFlag::Invalidate,
MsFlag::ReturnKey,
MsFlag::Opaque("opaque".to_string()),
MsFlag::ReturnSize,
MsFlag::Ttl(-1),
MsFlag::Mode(MsMode::Set),
MsFlag::Autovivify(0),
],
b"hi",
)
.await?;
assert_eq!(
result,
MsItem {
success: false,
cas: Some(0),
key: Some("44OG44K544OI".to_string()),
opaque: Some("opaque".to_string()),
size: Some(2),
base64_key: true
}
);Sourcepub async fn md(
&mut self,
key: impl AsRef<[u8]>,
flags: &[MdFlag],
) -> Result<MdItem>
pub async fn md( &mut self, key: impl AsRef<[u8]>, flags: &[MdFlag], ) -> Result<MdItem>
§Example
use mcmc_rs::{ClientHashRing, Connection, MdFlag, MdItem};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
let result = client
.md(
b"44OG44K544OI",
&[
MdFlag::Base64Key,
MdFlag::CompareCas(0),
MdFlag::NewCas(0),
MdFlag::Invalidate,
MdFlag::ReturnKey,
MdFlag::Opaque("opaque".to_string()),
MdFlag::UpdateTtl(-1),
MdFlag::LeaveKey,
],
)
.await?;
assert_eq!(
result,
MdItem {
success: false,
key: Some("44OG44K544OI".to_string()),
opaque: Some("opaque".to_string()),
base64_key: true
}
);Sourcepub async fn ma(
&mut self,
key: impl AsRef<[u8]>,
flags: &[MaFlag],
) -> Result<MaItem>
pub async fn ma( &mut self, key: impl AsRef<[u8]>, flags: &[MaFlag], ) -> Result<MaItem>
§Example
use mcmc_rs::{ClientHashRing, Connection, MaFlag, MaItem, MaMode};
let mut client = ClientHashRing::new(vec![
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
]);
let result = client
.ma(
b"aGk=",
&[
MaFlag::Base64Key,
MaFlag::CompareCas(0),
MaFlag::NewCas(0),
MaFlag::AutoCreate(0),
MaFlag::InitValue(0),
MaFlag::DeltaApply(0),
MaFlag::UpdateTtl(0),
MaFlag::Mode(MaMode::Incr),
MaFlag::Opaque("opaque".to_string()),
MaFlag::ReturnTtl,
MaFlag::ReturnCas,
MaFlag::ReturnValue,
MaFlag::ReturnKey,
],
)
.await?;
assert_eq!(
result,
MaItem {
success: true,
opaque: Some("opaque".to_string()),
ttl: Some(-1),
cas: Some(0),
number: Some(0),
key: Some("aGk=".to_string()),
base64_key: true
}
);Auto Trait Implementations§
impl Freeze for ClientHashRing
impl RefUnwindSafe for ClientHashRing
impl Send for ClientHashRing
impl Sync for ClientHashRing
impl Unpin for ClientHashRing
impl UnsafeUnpin for ClientHashRing
impl UnwindSafe for ClientHashRing
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