redis_utils

Cohesive helpers built on top of redis-rs for:

Async Transactions

A macro that helps you set up a safe async redis transaction.

Takes:

```rust tx!(&mut con, pipe, &["key1"], { let mut value: u8 = con.get("key1").await?; value = value + 1;

Ok(pipe.set("key1", value)) }); ```

Aborting a tx

```rust tx!(&mut con, pipe, &["key1"], { let mut value: u8 = con.get("key1").await?; value = value + 1;

if value == 69 { return Err(Abort(BadNumberFound)); }

Ok(pipe.set("key1", value)) }); ```

Handling return values

```rust let tx: Result > = tx!(&mut con, pipe, &["key1"], { let mut value: u8 = con.get("key1").await?; value = value + 1;

if value == 69 { return Err(Abort(BadNumberFound)); }

Ok(pipe.set("key1", value)) }); ```

JSON helpers

Using the helpers from TODO allow you to turn this:

rust let json_string: String = con.get(key).await?; let value: Type = serde_json::from_str(&json_string).unwrap;

rust let value: Type = con.json_get(key).await.unwrap();