21 个版本 (8 个破坏性更新)

0.9.0 2021 年 3 月 24 日
0.7.2 2021 年 3 月 9 日

#2137数据库接口

Download history 19/week @ 2024-04-08 71/week @ 2024-04-15 24/week @ 2024-04-22 65/week @ 2024-04-29 62/week @ 2024-05-06 49/week @ 2024-05-13 31/week @ 2024-05-20 15/week @ 2024-05-27 24/week @ 2024-06-03 12/week @ 2024-06-10 10/week @ 2024-06-17 57/week @ 2024-06-24 32/week @ 2024-07-01 21/week @ 2024-07-08 31/week @ 2024-07-15 21/week @ 2024-07-22

每月下载 108

MIT 许可证

19KB
436

RedisRS

一个简单的用于与 Redis 通信的 Rust 库。


lib.rs:

RedisRs

一个简单的 Redis 客户端库。此库围绕 Connection 结构体构建。每个请求都通过 Connection 方法发送。也可以使用 send_raw_request 函数发送请求。示例 创建连接并发送请求

 extern crate redis_rs;
 use std::net::TcpStream;
 use redis_rs::connection::Connection;
 use redis_rs::response::RedisResponse;

 let host = "127.0.0.1";
 let port = 6379;
 let addr = format!("{}:{}", host, port);
 let stream = TcpStream::connect(addr).unwrap();

 // stream can be anything that implements read and write
 let mut client = Connection::new(host, port, stream);

 // send a request
 let _ = client.send_raw_request("SET FOO BAR");
 // or use a supported command
 let response = client.get("FOO").unwrap();

 // match against the response to extract the value
 if let RedisResponse::BulkString(value) = response {
   println!("{}", value);
 }

无运行时依赖