use redis::Script;
use std::sync::OnceLock;
pub struct RedisScripts;
impl RedisScripts {
pub fn all() -> [&'static Script; 3] {
[
Self::load_cardinality(),
Self::load_global_quota(),
Self::load_is_rate_limited(),
]
}
pub fn load_cardinality() -> &'static Script {
static SCRIPT: OnceLock<Script> = OnceLock::new();
SCRIPT.get_or_init(|| Script::new(include_str!("scripts/cardinality.lua")))
}
pub fn load_global_quota() -> &'static Script {
static SCRIPT: OnceLock<Script> = OnceLock::new();
SCRIPT.get_or_init(|| Script::new(include_str!("scripts/global_quota.lua")))
}
pub fn load_is_rate_limited() -> &'static Script {
static SCRIPT: OnceLock<Script> = OnceLock::new();
SCRIPT.get_or_init(|| Script::new(include_str!("scripts/is_rate_limited.lua")))
}
}