Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

616 B
Raw Blame
use anyhow::Context;
use redis::AsyncCommands;

/// Sets a value in redis with the expiry
pub async fn set_with_expiry<T>(
    client: &redis::Client,
    key: &str,
    value: T,
    expiry_seconds: u64,
) -> anyhow::Result<()>
where
    T: redis::ToSingleRedisArg + Send + Sync,
{
    let mut redis_connection = client
        .get_multiplexed_async_connection()
        .await
        .context("unable to connect to redis")?;

    redis_connection
        .set_ex::<&str, T, ()>(key, value, expiry_seconds)
        .await
        .with_context(|| format!("unable to set key {} with expiry", key))?;

    Ok(())
}