# redius **Repository Path**: wxmayifei/redius ## Basic Information - **Project Name**: redius - **Description**: a faster async and multiplexing redis driver, for the convenience to users - **Primary Language**: Rust - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 13 - **Forks**: 3 - **Created**: 2024-07-05 - **Last Updated**: 2024-12-22 ## Categories & Tags **Categories**: database-dev **Tags**: redis-driver, Redis, Rust, Redis-Client ## README # Redius a faster async and multiplexing redis driver, for the convenience to users we are keep improving ### Supported Version - [x] >= 6.0 ### Supported Protocol - [ ] RESP2 - [X] RESP3 ### Supported Redis Mode - [x] Standalone - [ ] Cluster (developing) - [ ] Sentinel (developing) ### Supported Types - [X] String - [X] List - [X] Set - [ ] Sorted Set (zset) (developing) - [ ] Hash (developing) - [ ] Stream (developing) - [ ] Json (developing, need the `ReJson` module) - [ ] Other Commands ### Simple Example ```rust let builder = redius::RedisClientBuilder::new_standalone("127.0.0.1", 6379) .password("password"); match builder.build_and_connect().await { Ok(client) => { println!("connedted"); client.lpush("mylist","1").await?; let client2 = client.clone(); client2.lpush("mylist","2").await?; } Err(err) => { eprintln!("{err}"); } } ``` > in above example, we use `client.clone()` to clone a new client called `client2`, they are still use the same connection. > the feature of `clone` temporarily disable ### Subscribe > subscribe is command which let the connection be exclusived > > if we start a subscribe, the client (include cloned client) can't do anything else until exit(unsubscribe) ```rust let builder = redius::client::RedisClientBuilder::new_standalone("192.168.128.131", 6379) .password("111111") .reconnect_interval(Duration::from_secs(3)) .receive_timeout(Duration::from_secs(30)) .timeout(Duration::from_secs(55)); let client = builder.build_and_connect().await?; // start subscribe match client.subscribe_more(&["q1", "q2", "q3"]).await { Ok(mut stream) => { loop { match stream.recv().await { Ok(Some(val)) => match String::from_utf8(val.content) { Ok(str) => { if str == "exit" { println!("subscribe exit"); break; } else { println!( "receive from channel = {}, contnet = {}", val.channel, str ) } } Err(err) => { eprintln!("{err:?}"); } }, Ok(None) => { break; } Err(err) => { eprintln!("{err:?}"); } } } // unsubscribe and return the orginal client let _client2 = stream.exit().await; } Err(err) => { eprintln!("{err:?}"); } } ``` ### Blocking the following commands will blocked the connection until timeout - blpop - brpop - xread (when use `BLOCK` arg) ### Redis References [RESP3 Specification](https://redis.io/docs/reference/protocol-spec/#resp-versions) [Redis Commands](https://redis.io/commands/)