RedisGo
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.
Installation
Add the following to your Cargo.toml:
[]
= "*"
Usage
Initialization
Ensure your .env file contains the REDIS_URL variable:
REDIS_URL=redis://127.0.0.1/
Basic Operations
Set a Key
set?;
Get a Key
let value = get?;
Delete a Key
delete.unwrap;
Check if a Key Exists
let exists = exists.unwrap;
Flush All Keys
flush_all.unwrap;
Advanced Operations
Set a Key with TTL
set_with_ttl.unwrap; // TTL in seconds
Ping Redis
let response = ping.unwrap;
Get Connection Status
let status = get_connection_status;
Get Client Info
let info = get_client_info;
Example Usage
Here is an example of how to use the RedisGo library to implement a simple counter:
use RedisGo;
Rusty Rails Project
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.
Contributing
Contributions to the RedisGo library are welcome! Feel free to open issues, submit pull requests, or provide feedback to help improve this library.