rsmc-tokio

Crates.iorsmc-tokio
lib.rsrsmc-tokio
version0.4.0
sourcesrc
created_at2021-04-08 23:04:17.891172
updated_at2021-12-20 20:34:07.148666
descriptionAn async memcached client for Tokio
homepage
repositoryhttps://github.com/crestonbunch/rsmc
max_upload_size
id381068
size11,285
Creston Bunch (crestonbunch)

documentation

README

rsmc-tokio

This crate aims to provide a full-features memcached client for the Tokio async runtime using rsmc-core.

This is still an early implementation, so expect some bugs and missing features. If you find something is wrong, please open a GitHub issue (or, even better, a PR to fix the issue!)

Expect some breaking changes before a 1.0 release.

Features:

  • Async
  • Connection pooling provided by deadpool
  • TLS support
  • Binary protocol support
    • get, multi_get
    • set, multi_set
    • delete, multi_delete
    • add, replace
    • increment, decrement
  • Consistent hashing
    • Support for different hashing algorithms.
  • Compression
    • Support for different compression algorithms.

Quick start

use flate2::Compression;
use rsmc_core::{
    client::{ClientConfig, Pool},
    zlib::ZlibCompressor,
};
use rsmc_tokio::TokioConnection;


// Consistent hashing is used to distribute keys
// evenly across a memcached cluster.
let memcached_servers = vec![
    "localhost:11211",
    "localhost:11212",
    "localhost:11213",
];

// Use `ClientConfig::new_uncompressed()` if compression is not desired.
// You can disable the `zlib` feature (on by default) to disable it entirely.
let cfg = ClientConfig::new(memcached_servers, ZlibCompressor::default());

// Create a connection pool with (at most) 16 connections per server.
let pool = Pool::<TokioConnection, _>::new(cfg, 16);
let mut client = pool.get().await.unwrap();

client.set(b"hello", b"world", 300).await.unwrap();
let response: Option<Vec<u8>> = client.get(b"hello").await.unwrap(); // "world"
Commit count: 19

cargo fmt