10 releases

0.4.5-beta.2 Jun 21, 2023
0.4.4 May 12, 2020
0.3.0 May 11, 2020
0.2.0 May 10, 2020
0.1.0 May 9, 2020

#68 in Caching

MIT/Apache

63KB
1.5K SLoC

Memcached

Async memcached client built on Rust and Async-std


Features

This project is still under development. The following features with the check marks are supported.

If you are concerned about an unimplemented feature, please tell me and I will finish writing it ASAP.

  • Client Supported Method
    • add
    • append
    • cas
    • decrement
    • delete
    • flush
    • flush_with_delay
    • get
    • gets
    • increment
    • prepend
    • replace
    • set
    • stats
    • touch
    • version
  • Supported protocols
    • Binary protocol
    • ASCII protocol
  • All memcached supported connections
    • TCP connection
    • TLS connection
    • UDP connection
    • UNIX Domain socket connection
  • Encodings support Serde
    • Of course including but not limited to &[u8] / Vec<u8>
  • Memcached cluster support with custom key hash algorithm

Basic usage

This example uses async-std and enables some optional features, so your Cargo.toml could look like this:

[dependencies]
async-std = { version = "1", features = ["attributes"] }
memcached = "*"

And then the code:

#[async_std::test]
async fn it_works() -> memcached::Result<()> {
    let client = memcached::connect("memcache://127.0.0.1:12345")?;
    client.set("abc", "hello", 100).await?;
    let t: Option<String> = client.get("abc").await?;
    assert_eq!(t, Some("hello".to_owned()));
    Ok(())
}

For more usage, see doc, each method of client has example.

FAQ

Should I use this in production?

Better not.

This project needs a lot of details to complete. But if you want, you can try it.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions

Dependencies

~11–20MB
~292K SLoC