aboutsummaryrefslogtreecommitdiffstats
path: root/crates/sh-util/src/cache/key.rs
blob: 41315b8cdf7089fe79b64de8af605e04cc236fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use redis::{ToRedisArgs, ToSingleRedisArg};

pub enum CacheKey<'a> {
    Session(&'a str),
}

impl ToRedisArgs for CacheKey<'_> {
    fn write_redis_args<W>(&self, out: &mut W)
    where
        W: ?Sized + redis::RedisWrite,
    {
        out.write_arg(
            match self {
                CacheKey::Session(id) => {
                    format!("session:{id}")
                }
            }
            .as_bytes(),
        );
    }
}

impl ToSingleRedisArg for CacheKey<'_> {}