#memcached #async #memcache #tokio

yamemcache

Yet Another memcached client library

3 releases

0.0.5 Apr 12, 2023
0.0.4 Dec 7, 2022
0.0.3 Dec 1, 2022
0.0.2 Nov 30, 2022
0.0.1 Nov 29, 2022

#165 in Caching

MIT license

25KB
523 lines

This crate exists because I need an async (either runtime-agnostic or tokio-based) rust memcached client that uses metadata when deserializing. Current implementations that I know of don't allow me to do that:

  • rsmc: tokio 1.x, no access to metadata
  • memcached: async-std, no access to metadata
  • memcache: synchronous, access to metadata
  • memcache-async: futures, no access to metadata
  • async-memcached: tokio 0.2, access to metadata
  • memcached-rs: synchronous, access to metadata
  • vmemcached: tokio 1.x, no access to metadata

It will most likely break at some point. It's NOT production ready.


lib.rs:

Yet another memcached client

This is yet another memcached client since none of the existing ones at the same time:

  • use a new version of tokio (1.x)
  • allow access to flags when accessing the data

Example usage

#[tokio::main]
async fn main() {
  let Ok(stream) = tokio::net::TcpStream::connect("127.0.0.1:11211").await
    .map(tokio::io::BufStream::new) else {
    println!("Unable to connect");
    return;
  };

  let mut client = yamemcache::Client::new(stream);

  if let Ok(x) = client.get("hello").await {
    match x {
      Some(x) => println!("Received data: {}", String::from_utf8_lossy(&x.data)),
      None => println!("No data received"),
    }
  }
}

Dependencies

~2.2–3.5MB
~50K SLoC