mcmc-rs

Crates.iomcmc-rs
lib.rsmcmc-rs
version0.7.1
created_at2025-04-24 19:03:51.831766+00
updated_at2026-01-19 07:54:09.164782+00
descriptionMinimal rust client for memcached
homepage
repositoryhttps://github.com/ArtemIsmagilov/mcmc-rs
max_upload_size
id1647662
size253,891
(ArtemIsmagilov)

documentation

README

Minimal Rust client for Memcached

ci crates.io docs.rs

Asynchronous memcached client on Rust.

This crate provides working with memcached server. All methods implemented. Available TCP/Unix/UDP connections.

  • [Connection] is a Enum that represents a connection to memcached server.
  • [Pipeline] is a structure that represents a pipeline of memcached commands.
  • [WatchStream] is a structure that represents a stream of watch events.
  • [ClientCrc32] is a structure that represents a Cluster connections for memcached server.

Example

Connection mode

use smol::{block_on, io};

use mcmc_rs::Connection;

fn main() -> io::Result<()> {
    block_on(async {
        let mut conn = Connection::default().await?;
        conn.set(b"key", 0, 0, false, b"value").await?;
        let item = conn.get(b"key").await?.unwrap();
        println!("{item:#?}");
        Ok(())
    })
}

Cluster mode

use smol::{block_on, io};

use mcmc_rs::{ClientCrc32, Connection};

fn main() -> io::Result<()> {
    block_on(async {
        let mut client = ClientCrc32::new(vec![
            Connection::default().await?,
            Connection::tcp_connect("127.0.0.1:11212").await?,
        ]);
        client.set(b"key", 0, 0, false, b"value").await?;
        let item = client.get(b"key").await?.unwrap();
        println!("{item:#?}");
        Ok(())
    })
}

Pipeline mode

use smol::{block_on, io};

use mcmc_rs::Connection;

fn main() -> io::Result<()> {
    block_on(async {
        let mut conn = Connection::default().await?;
        let r = conn
            .pipeline()
            .set("key", 0, 0, false, "A")
            .set("key2", 0, 0, false, "A")
            .get("key")
            .get("key2")
            .version()
            .execute()
            .await?;
        println!("{r:#?}");
        Ok(())
    })
}

Pool mode

use smol::{block_on, io};

use mcmc_rs::{AddrArg, Manager, Pool};

fn main() -> io::Result<()> {
    block_on(async {
        let mgr = Manager::new(AddrArg::Tcp("127.0.0.1:11211"));
        let pool = Pool::builder(mgr).build().unwrap();
        let mut conn = pool.get().await.unwrap();
        let result = conn.version().await?;
        println!("{result:#?}");
        Ok(())
    })
}

Watch mode

use smol::{block_on, io};

use mcmc_rs::{Connection, WatchArg};

fn main() -> io::Result<()> {
    block_on(async {
        let mut conn = Connection::default().await?;
        let mut w = conn.watch(&[WatchArg::Fetchers]).await?;
        let mut conn = Connection::default().await?;
        conn.get(b"key").await?;
        println!("{:#?}", w.message().await?);
        Ok(())
    })
}

Tests

docker compose up
bash chmod_unix.bash
cargo test
docker compose down

Benchmarks

cargo bench

Test coverage

cargo llvm-cov

Mutation testing

cargo mutants

Links

Commit count: 108

cargo fmt