Crates.io | redis-queue-rs |
lib.rs | redis-queue-rs |
version | 0.1.7 |
source | src |
created_at | 2024-03-28 06:10:05.127216 |
updated_at | 2024-07-24 06:12:35.058876 |
description | Redis Queue with sync and async support for Rust |
homepage | |
repository | https://github.com/HideyoshiNakazone/redis-queue-rs.git |
max_upload_size | |
id | 1188785 |
size | 35,127 |
A simple Redis queue implementation in Rust.
This project ofers two implementations: RedisQueue
and AsyncRedisQueue
.
Both of them are based on the same RedisQueue struct and are thread safe due to the use of a Redis key based lock,
but the AsyncRedisQueue uses async/await to handle the Redis connection.
This project is considered a work in progress and is not yet ready for production use.
Add the following to your Cargo.toml:
[dependencies]
redis-queue-rs = "*"
use redis_queue_rs::redis_queue::RedisQueue;
use redis::Client;
fn main() {
let redis_client = Client::open("redis://127.0.0.1:6379").unwrap();
let mut redis_queue = RedisQueue::new(
"name_of_queue".to_string(),
redis_client,
);
let item = "test".to_string();
redis_queue.push(item.clone());
let result = redis_queue.pop().unwrap();
}
use redis_queue_rs::async_redis_queue::AsyncRedisQueue;
use redis::Client;
#[tokio::main]
async fn main() {
let redis_client = Client::open("redis://127.0.0.1:6379").unwrap();
let mut redis_queue = AsyncRedisQueue::new(
"name_of_queue".to_string(),
redis_client,
).await;
let item = "test".to_string();
redis_queue.push(item.clone()).await;
let result = redis_queue.pop().await.unwrap();
}
This project is licensed under the MIT License, feel free to use it in your projects :)