Rust

redis_conn

Module

Redis plumbing shared by the Redis stores: replies as phpredis reports them, key scans, and the Pool the RedisPool stores borrow from.

Contents

use utopia_abuse::redis_conn::Counter;
Rust
pub struct Counter

One counter in Redis, as the logs list it.

use utopia_abuse::redis_conn::Lent;
Rust
pub struct Lent<'a>

A connection borrowed from a Stack.

Also implements Deref, DerefMut, Drop.
use utopia_abuse::Stack;
Rust
pub struct Stack

A pool of up to size connections made on demand and reused last in, first out.

Rust
use utopia_abuse::{Connection, Stack, TimeLimit, time_limit};

let client = redis::Client::open("redis://127.0.0.1:6379")?;
let pool = Stack::new(2, move || {
    let client = client.clone();
    async move { Ok(Connection::Redis(client.get_connection_manager().await?)) }
});
let limit = TimeLimit::new("ip:{ip}", 10, 60, time_limit::RedisPool::new(pool))?;
Compiles in CI; needs a running service to execute.
Also implements Debug.
use utopia_abuse::Connection;
Rust
pub enum Connection

A connection a Pool lends: to one Redis server, or to a cluster.

Also implements Debug.
use utopia_abuse::Pool;
Rust
pub trait Pool: Send + Sync

Lends Connections for the duration of one operation. Implement it to back the RedisPool stores with another pool.

Implemented byStackArc