pub enum Connection {
Tcp(BufReader<TcpStream>),
Unix(BufReader<UnixStream>),
Udp(UdpSocket, u16),
Tls(BufReader<TlsStream<TcpStream>>),
}Variants§
Tcp(BufReader<TcpStream>)
Unix(BufReader<UnixStream>)
Udp(UdpSocket, u16)
Tls(BufReader<TlsStream<TcpStream>>)
Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn tcp_connect(addr: &str) -> Result<Self>
pub async fn tcp_connect(addr: &str) -> Result<Self>
§Example
let mut conn = Connection::tcp_connect("127.0.0.1:11211").await?;Sourcepub async fn unix_connect(path: &str) -> Result<Self>
pub async fn unix_connect(path: &str) -> Result<Self>
§Example
let mut conn = Connection::unix_connect("/tmp/memcached0.sock").await?;Sourcepub async fn udp_connect(bind_addr: &str, connect_addr: &str) -> Result<Self>
pub async fn udp_connect(bind_addr: &str, connect_addr: &str) -> Result<Self>
§Example
let mut conn = Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?;Sourcepub async fn tls_connect(
hostname: &str,
port: u16,
ca_path: &str,
) -> Result<Self>
pub async fn tls_connect( hostname: &str, port: u16, ca_path: &str, ) -> Result<Self>
§Example
let mut conn = Connection::tls_connect("localhost", 11216, "cert.pem").await?;Sourcepub async fn version(&mut self) -> Result<String>
pub async fn version(&mut self) -> Result<String>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.version().await?;
assert!(result.chars().any(|x| x.is_numeric()));
}Sourcepub async fn quit(self) -> Result<()>
pub async fn quit(self) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.quit().await?;
}Sourcepub async fn shutdown(self, graceful: bool) -> Result<()>
pub async fn shutdown(self, graceful: bool) -> Result<()>
§Example
for mut c in [
Connection::tcp_connect("127.0.0.1:11213").await?,
Connection::unix_connect("/tmp/memcached1.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11215").await?,
Connection::tls_connect("localhost", 11217, "cert.pem").await?,
] {
c.shutdown(true).await?;
}Sourcepub async fn cache_memlimit(
&mut self,
limit: usize,
noreply: bool,
) -> Result<()>
pub async fn cache_memlimit( &mut self, limit: usize, noreply: bool, ) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.cache_memlimit(10, true).await?;
}Sourcepub async fn flush_all(
&mut self,
exptime: Option<i64>,
noreply: bool,
) -> Result<()>
pub async fn flush_all( &mut self, exptime: Option<i64>, noreply: bool, ) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.flush_all(Some(999), true).await?;
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.set(b"key", 0, -1, true, b"value").await?;
assert!(result);
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.add(b"key", 0, -1, true, b"value").await?;
assert!(result);
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.replace(b"key", 0, -1, true, b"value").await?;
assert!(result);
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.append(b"key", 0, -1, true, b"value").await?;
assert!(result);
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.prepend(b"key", 0, -1, true, b"value").await?;
assert!(result);
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.cas(b"key", 0, -1, 0, true, b"value").await?;
assert!(result);
}Sourcepub async fn auth(
&mut self,
username: impl AsRef<[u8]>,
password: impl AsRef<[u8]>,
) -> Result<()>
pub async fn auth( &mut self, username: impl AsRef<[u8]>, password: impl AsRef<[u8]>, ) -> Result<()>
§Example
for mut c in [
Connection::tcp_connect("127.0.0.1:11212").await?,
Connection::unix_connect("/tmp/memcached2.sock").await?,
Connection::tls_connect("localhost", 11218, "cert.pem").await?,
] {
c.auth(b"a", b"a").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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.delete(b"key", true).await?;
assert!(result);
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.incr(b"key", 1, true).await?;
assert!(result.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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.decr(b"key", 1, true).await?;
assert!(result.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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.touch(b"key", -1, true).await?;
assert!(result);
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.set(b"k1", 0, 0, false, b"v1").await?);
let result = c.get(b"k1").await?;
assert_eq!(result.unwrap().key, "k1");
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.set(b"k2", 0, 0, false, b"v2").await?);
let result = c.gets(b"k2").await?;
assert_eq!(result.unwrap().key, "k2");
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.set(b"k3", 0, 0, false, b"v3").await?);
let result = c.gat(0, b"k3").await?;
assert_eq!(result.unwrap().key, "k3");
}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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.set(b"k4", 0, 0, false, b"v4").await?);
let result = c.gats(0, b"k4").await?;
assert_eq!(result.unwrap().key, "k4");
}Sourcepub async fn get_multi(
&mut self,
keys: &[impl AsRef<[u8]>],
) -> Result<Vec<Item>>
pub async fn get_multi( &mut self, keys: &[impl AsRef<[u8]>], ) -> Result<Vec<Item>>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.set(b"k8", 0, 0, false, b"v8").await?);
let result = c.get_multi(&[b"k8"]).await?;
assert_eq!(result[0].key, "k8");
}Sourcepub async fn gets_multi(
&mut self,
keys: &[impl AsRef<[u8]>],
) -> Result<Vec<Item>>
pub async fn gets_multi( &mut self, keys: &[impl AsRef<[u8]>], ) -> Result<Vec<Item>>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.set(b"k7", 0, 0, false, b"v7").await?);
let result = c.gets_multi(&[b"k7"]).await?;
assert_eq!(result[0].key, "k7");
}Sourcepub async fn gat_multi(
&mut self,
exptime: i64,
keys: &[impl AsRef<[u8]>],
) -> Result<Vec<Item>>
pub async fn gat_multi( &mut self, exptime: i64, keys: &[impl AsRef<[u8]>], ) -> Result<Vec<Item>>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.set(b"k6", 0, 0, false, b"v6").await?);
let result = c.gat_multi(0, &[b"k6"]).await?;
assert_eq!(result[0].key, "k6");
}Sourcepub async fn gats_multi(
&mut self,
exptime: i64,
keys: &[impl AsRef<[u8]>],
) -> Result<Vec<Item>>
pub async fn gats_multi( &mut self, exptime: i64, keys: &[impl AsRef<[u8]>], ) -> Result<Vec<Item>>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.set(b"k5", 0, 0, false, b"v5").await?);
let result = c.gats_multi(0, &[b"k5"]).await?;
assert_eq!(result[0].key, "k5");
}Sourcepub async fn stats(
&mut self,
arg: Option<StatsArg>,
) -> Result<HashMap<String, String>>
pub async fn stats( &mut self, arg: Option<StatsArg>, ) -> Result<HashMap<String, String>>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.stats(None).await?;
assert!(result.len() > 0);
}Sourcepub async fn slabs_automove(&mut self, arg: SlabsAutomoveArg) -> Result<()>
pub async fn slabs_automove(&mut self, arg: SlabsAutomoveArg) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.slabs_automove(SlabsAutomoveArg::Zero).await?;
}Sourcepub async fn lru_crawler(&mut self, arg: LruCrawlerArg) -> Result<()>
pub async fn lru_crawler(&mut self, arg: LruCrawlerArg) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.lru_crawler(LruCrawlerArg::Enable).await;
assert!(result.is_err());
}Sourcepub async fn lru_crawler_sleep(&mut self, microseconds: usize) -> Result<()>
pub async fn lru_crawler_sleep(&mut self, microseconds: usize) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.lru_crawler_sleep(1_000_000).await?;
}Sourcepub async fn lru_crawler_tocrawl(&mut self, arg: u32) -> Result<()>
pub async fn lru_crawler_tocrawl(&mut self, arg: u32) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.lru_crawler_tocrawl(0).await?;
}Sourcepub async fn lru_crawler_crawl(
&mut self,
arg: LruCrawlerCrawlArg<'_>,
) -> Result<()>
pub async fn lru_crawler_crawl( &mut self, arg: LruCrawlerCrawlArg<'_>, ) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.lru_crawler_crawl(LruCrawlerCrawlArg::All).await?;
}Sourcepub async fn slabs_reassign(
&mut self,
source_class: isize,
dest_class: isize,
) -> Result<()>
pub async fn slabs_reassign( &mut self, source_class: isize, dest_class: isize, ) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c.slabs_reassign(1, 2).await;
assert!(result.is_err());
}Sourcepub async fn lru_crawler_metadump(
&mut self,
arg: LruCrawlerMetadumpArg<'_>,
) -> Result<Vec<String>>
pub async fn lru_crawler_metadump( &mut self, arg: LruCrawlerMetadumpArg<'_>, ) -> Result<Vec<String>>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c
.lru_crawler_metadump(LruCrawlerMetadumpArg::Classids(&[2]))
.await?;
assert!(result.is_empty());
}Sourcepub async fn lru_crawler_mgdump(
&mut self,
arg: LruCrawlerMgdumpArg<'_>,
) -> Result<Vec<String>>
pub async fn lru_crawler_mgdump( &mut self, arg: LruCrawlerMgdumpArg<'_>, ) -> Result<Vec<String>>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c
.lru_crawler_mgdump(LruCrawlerMgdumpArg::Classids(&[2]))
.await?;
assert!(result.is_empty());
}Sourcepub async fn mn(&mut self) -> Result<()>
pub async fn mn(&mut self) -> Result<()>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.mn().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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
c.set(b"k9", 0, 0, false, b"v9").await?;
assert!(c.me(b"k9").await?.is_some());
}Sourcepub async fn watch(self, arg: &[WatchArg]) -> Result<WatchStream>
pub async fn watch(self, arg: &[WatchArg]) -> Result<WatchStream>
§Example
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.watch(&[WatchArg::Fetchers]).await.is_ok())
}pub fn pipeline(&mut self) -> Pipeline<'_>
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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c
.mg(
b"44OG44K544OI",
&[
MgFlag::Base64Key,
MgFlag::ReturnCas,
MgFlag::CheckCas(99),
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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c
.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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c
.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
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
let result = c
.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
}
);
}Sourcepub async fn lru(&mut self, arg: LruArg) -> Result<()>
pub async fn lru(&mut self, arg: LruArg) -> Result<()>
§Example
use mcmc_rs::{Connection, LruArg, LruMode};
for mut c in [
Connection::default().await?,
Connection::unix_connect("/tmp/memcached0.sock").await?,
Connection::udp_connect("127.0.0.1:0", "127.0.0.1:11214").await?,
Connection::tls_connect("localhost", 11216, "cert.pem").await?,
] {
assert!(c.lru(LruArg::Mode(LruMode::Flat)).await.is_ok())
}Auto Trait Implementations§
impl Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
impl UnwindSafe for Connection
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