#redis #async #database


Async Redis client using std::future

17 releases

0.8.0 Feb 13, 2021
0.7.0 Mar 7, 2020
0.6.1 Jan 9, 2020
0.5.2 Dec 14, 2019
0.2.0 Jul 31, 2019

#21 in Database interfaces

Download history 254/week @ 2021-04-03 257/week @ 2021-04-10 184/week @ 2021-04-17 46/week @ 2021-04-24 37/week @ 2021-05-01 30/week @ 2021-05-08 50/week @ 2021-05-15 34/week @ 2021-05-22 34/week @ 2021-05-29 68/week @ 2021-06-05 41/week @ 2021-06-12 43/week @ 2021-06-19 74/week @ 2021-06-26 54/week @ 2021-07-03 53/week @ 2021-07-10 73/week @ 2021-07-17

1,382 downloads per month
Used in 6 crates (3 directly)

Zlib license

2.5K SLoC

darkredis : A Redis client based on std::future and async_await

Documentation Build Status Crates.io Status

darkredis is a Redis client for Rust written using the new std::future and async_await. It's designed to be easy to use, and lacks advanced features. Requires rust 1.39.0 or newer.

Currently not all Redis commands have convenience functions, and there may be ergonomic improvements to make.


As of version 0.8.0, darkredis is no longer maintained.


When darkredis was originally written, it was part of an async project. At the time, there was no real way to use .await with redis-rs, so I set out to change that. The result is darkredis, and it has worked very well for my own personal use, which it might for you too. It's designed to be as simple as possible, serving as an easy way to call redis commands.

Cargo features

  • runtime_tokio(on by default): Use the tokio 0.2 runtime and Tcp primitives. Requires a running tokio 0.2 runtime.
  • runtime_async_std: Use async-std instead of tokio, using it's runtime instead of tokio. Is mutually exclusive with the runtime_tokio feature.

Getting started

  • Add darkredis and to your Cargo.toml.
  • Create an async context somehow, for instance by using tokio 0.2.
  • Create a ConnectionPool and grab a connection!
use darkredis::ConnectionPool;

async fn main() -> darkredis::Result<()> {
    let pool = ConnectionPool::create("".into(), None, num_cpus::get()).await?;
    let mut conn = pool.get().await;

    //And away!
    conn.set("secret_entrance", b"behind the bookshelf").await?;
    let secret_entrance = conn.get("secret_entrance").await?;
    assert_eq!(secret_entrance, Some("behind the bookshelf".into()));

    //Keep our secrets




Breaking changes

  • Update tokio to 1.0
  • Update dependencies
  • Move away from futures mutexes to async-std/tokio mutexes.


This is likely to be the last release. Don't expect any updates.


Breaking changes

  • Change the blpop and brpop commands to return a tuple instead an unnecesarry vector.
  • Added new error variant: EmptySlice
  • del, sadd now return bool.


  • Properly parse nested arrays.
  • Convenience functions now return an error if a given slice is empty.


  • Add support for SCAN, SSCAN and HSCAN.
  • Convenience function for the TYPE command.
  • Add convenience functions for all set commands.


Breaking changes

  • Change run_commands to return a stream.
  • Rename runtime_agnostic feature to runtime_async_std
  • Split Connection::connect into one which authenticates and one which doesn't.
  • Connection password now takes AsRef<[u8]> instead of forcing a string.
  • Remove deprecated function set_with_expiry
  • Change MSET to use the new MSetBuilder struct


  • Hashmap convenience functions
  • Add some convenience functions for sets
  • Allow running commands using a pre-allocated serialization buffer
  • Most types now implement Debug


  • Improve serialization performance by 50%! 🎉
  • Add benchmarks


  • Add blpop and brpop


  • Update to tokio 0.2.3 and async-std 1.2.0
  • Add expiry commands
  • Connection: deprecate set_with_expiry, use set_and_expire_seconds and set_and_expire_ms instead.


  • Updated to async-std 1.0.1 and futures 0.3.1


  • (BREAKING) Add the runtime_agnostic and runtime_tokio features.
  • Simple Pubsub support using the MessageStream and PMessageStream types.
  • Ability to spawn a new connection using the settings from a ConnectionPool
  • Use tokio in test mode.
  • Add convenience function for PUBLISH
  • Add pubsub example
  • Add variants of builder functions for Command and CommandList which mutate the object instead of moving it.


  • Expclicitly use traits from async-std, not std. This fixes compilation on async-std 0.99.5


  • Add convenience functions for the INCR and DECR family of commands, as well as for APPEND, MGET, MSET, EXISTS.
  • Improve the documentation of convenience functions
  • Allow renaming of client connections in connection pools


  • Use async-std instead of runtime for TcpStream, allowing using darkredis with any runtime.


  • Update dependencies


  • Fix compilation error on latest nightly


  • Command and CommandList no longer perform any copies
  • Added args method to Command and CommandList
  • lpush and rpush now take multiple arguments
  • Support password auth
  • lrange no longer returns an Option, returns an empty vec instead.
  • Add convenience functions for the following commands: lset, ltrim


  • Remove unnecesarry generic parameter from lpop and rpop methods.


  • Fix a couple documentation errors


  • Initial release


If you're hacking on darkredis and want to run the tests, make sure you have a Redis instance running on your local machine on port 6379. The tests clean up any keys set by themselves, unless the test fails. Please submit an issue if it does not.

Also, make sure to run the tests using both the runtime_tokio and runtime_async_std features, to make sure that it works.


~59K SLoC