redis
ModuleFixed-window counters in Redis: one string per key and window,
abuse__<key>__<window start>, expiring with the window.
Contents
use utopia_abuse::time_limit::redis::Redis;Rust
pub struct Redis<C = ConnectionManager>Counters in one Redis server.
Rust
use utopia_abuse::{Adapter, TimeLimit, time_limit};
let conn = redis::Client::open("redis://127.0.0.1:6379")?.get_connection_manager().await?;
let limit = TimeLimit::new("ip:{ip}", 60, 60, time_limit::Redis::new(conn))?.with_param("{ip}", "203.0.113.7");
if limit.check().await?.limited {
println!("slow down");
}Compiles in CI; needs a running service to execute.
Also implements
Debug.use utopia_abuse::time_limit::redis::RedisCluster;Rust
pub struct RedisClusterCounters in a Redis Cluster.
Also implements
Debug.use utopia_abuse::time_limit::redis::RedisPool;Rust
pub struct RedisPool<P>Counters in Redis or a Redis Cluster, through connections borrowed from
a Pool for each operation.
Also implements
Clone, Debug.Rust
pub const NAMESPACE: &str = redis_conn::NAMESPACEThe prefix of every key the Redis stores write.