Crates.io | darkredis |
lib.rs | darkredis |
version | 0.8.0 |
source | src |
created_at | 2019-07-26 16:03:45.454102 |
updated_at | 2021-02-13 10:33:53.112135 |
description | Async Redis client using std::future |
homepage | |
repository | https://github.com/Bunogi/darkredis |
max_upload_size | |
id | 151803 |
size | 151,670 |
std::future
and async_await
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.
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.darkredis
and to your Cargo.toml
.tokio
0.2.ConnectionPool
and grab a connection!use darkredis::ConnectionPool;
#[tokio::main]
async fn main() -> darkredis::Result<()> {
let pool = ConnectionPool::create("127.0.0.1:6379".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
conn.del("secret_entrance").await?;
Ok(())
}
This is likely to be the last release. Don't expect any updates.
del
, sadd
now return bool
.run_commands
to return a stream.runtime_agnostic
feature to runtime_async_std
Connection::connect
into one which authenticates and one which doesn't.AsRef<[u8]>
instead of forcing a string.set_with_expiry
MSET
to use the new MSetBuilder
structDebug
set_with_expiry
, use set_and_expire_seconds
and set_and_expire_ms
instead.runtime_agnostic
and runtime_tokio
features.MessageStream
and PMessageStream
types.tokio
in test mode.PUBLISH
Command
and CommandList
which mutate the object instead of moving it.async-std
, not std
. This fixes compilation on async-std 0.99.5INCR
and DECR
family of commands, as well as for APPEND
, MGET
, MSET
, EXISTS
.async-std
instead of runtime
for TcpStream, allowing using darkredis with any runtime.lpush
and rpush
now take multiple argumentslrange
no longer returns an Option, returns an empty vec instead.lset
, ltrim
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.