| Crates.io | redisgo |
| lib.rs | redisgo |
| version | 0.1.3 |
| created_at | 2025-06-03 17:04:24.693806+00 |
| updated_at | 2026-01-03 11:24:06.636414+00 |
| description | A simple and ergonomic Redis client wrapper for Rust |
| homepage | https://github.com/mohamadzoh/redisgo |
| repository | https://github.com/mohamadzoh/redisgo |
| max_upload_size | |
| id | 1699310 |
| size | 44,954 |
RedisGo is a Rust library designed to simplify interactions with Redis, providing a convenient API for common Redis operations such as setting, getting, deleting keys, and more. It leverages the redis crate and includes features like connection management and .env file support for configuration.
Add the following to your Cargo.toml:
[dependencies]
redisgo = "*"
Ensure your .env file contains the REDIS_URL variable:
REDIS_URL=redis://127.0.0.1/
RedisGo::set("key", "value")?;
let value = RedisGo::get("key")?;
RedisGo::delete("key").unwrap();
let exists = RedisGo::exists("key").unwrap();
RedisGo::flush_all().unwrap();
RedisGo::set_with_ttl("key", "value", Some(60)).unwrap(); // TTL in seconds
let response = RedisGo::ping().unwrap();
let status = RedisGo::get_connection_status();
let info = RedisGo::get_client_info();
Here is an example of how to use the RedisGo library to implement a simple counter:
use redisgo::RedisGo;
fn main() {
println!("Hello, world!");
let counter_key = "counter";
match RedisGo::get(counter_key) {
Ok(Some(value)) => {
let count: i32 = value.parse().unwrap_or(0);
let new_count = count + 1;
RedisGo::set(counter_key, &new_count.to_string()).unwrap();
println!("Counter incremented to: {}", new_count);
}
Ok(None) => {
RedisGo::set(counter_key, "1").unwrap();
println!("Counter initialized to 1");
}
Err(e) => {
eprintln!("Error accessing Redis: {}", e);
}
}
println!("Hello, world!");
}
Rusty Rails is a larger project aiming to bridge the gap between Rust and Ruby/Ruby on Rails. We are actively working on recreating Ruby libraries into Rust that seamlessly make working in Rust more easy and fun for new developers.
Contributions to the RedisGo library are welcome! Feel free to open issues, submit pull requests, or provide feedback to help improve this library.