chore: datastore redis
This commit is contained in:
parent
28404160ed
commit
723fbca34e
16
src/handlers/datastores.rs
Normal file
16
src/handlers/datastores.rs
Normal file
@ -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(())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user