use anyhow::Result;
use redis::aio::MultiplexedConnection;
use redis::AsyncCommands;

const URL_REGISTRY_KEY: &str = "url_registry";

pub async fn add_url(conn: &mut MultiplexedConnection, url: &str) -> Result<()> {
    conn.sadd::<_, _, ()>(URL_REGISTRY_KEY, url).await?;
    Ok(())
}

pub async fn check_url(conn: &mut MultiplexedConnection, url: &str) -> Result<bool> {
    let exists: bool = conn.sismember(URL_REGISTRY_KEY, url).await?;
    Ok(exists)
}
