diff --git a/src/handlers/datastores.rs b/src/handlers/datastores.rs new file mode 100644 index 0000000..76fab16 --- /dev/null +++ b/src/handlers/datastores.rs @@ -0,0 +1,16 @@ +use redis::{AsyncCommands}; +use anyhow::{Result}; + +pub async fn on_redis_set_str ( + client: &redis::Client, + key: &str, + value: &str, + ttl_seconds: usize, +) -> Result<()> { + let mut con = client.get_async_connection().await?; + con.set(key, value).await?; + if ttl_seconds > 0 { + con.expire(key, ttl_seconds).await?; + } + Ok(()) +}