aboutsummaryrefslogtreecommitdiffstats
path: root/crates/configuration/src/state/cache_key.rs
blob: a63b15daa85aae3ed4997101c1a920b97a317f30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use warden_stack::redis::ToRedisArgs;

#[derive(Clone, Copy, Debug)]
pub enum CacheKey<'a> {
    ActiveRouting,
    Routing(&'a uuid::Uuid),
}

impl ToRedisArgs for CacheKey<'_> {
    fn write_redis_args<W>(&self, out: &mut W)
    where
        W: ?Sized + warden_stack::redis::RedisWrite,
    {
        let value = match self {
            CacheKey::ActiveRouting => "routing.active".into(),
            CacheKey::Routing(uuid) => format!("routing.{uuid}"),
        };

        out.write_arg(value.as_bytes());
    }
}