cloudiful-scheduler 0.4.2

Single-job async scheduling library for background work with optional Valkey-backed state.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use redis::AsyncCommands;

pub async fn delete_matching_prefix(
    connection: &mut redis::aio::MultiplexedConnection,
    prefix: &str,
) {
    let pattern = format!("{prefix}*");
    let keys: Vec<String> = redis::cmd("KEYS")
        .arg(pattern)
        .query_async(connection)
        .await
        .expect("failed to list prefixed keys");
    if !keys.is_empty() {
        let _: usize = connection.del(keys).await.expect("failed to cleanup keys");
    }
}