redis-lua 0.4.0

Redis Lua scripting helper
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![allow(unused)]

use redis::ScriptInvocation;

pub async fn run<T: redis::FromRedisValue + Send, S: redis_lua::Script + Send>(script: S) -> T {
    let cli = redis::Client::open("redis://127.0.0.1").unwrap();
    let mut con = cli.get_multiplexed_tokio_connection().await.unwrap();
    script.invoke_async(&mut con).await.unwrap()
}

macro_rules! test {
    ($type:ty { $($t:tt)* }, $exp:expr) => {{
        assert_eq!(crate::util::run::<$type, _>(redis_lua::lua! {
            $($t)*
        }).await, $exp);
    }}
}