blob: 756b7d0d0e0186084b6d5a401e202051fa5b7fc4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
use redis::{ToRedisArgs, ToSingleRedisArg};
#[derive(Clone, Copy)]
pub enum CacheKey<'a> {
Session(&'a str),
}
impl CacheKey<'_> {
pub fn key(&self) -> &str {
match self {
CacheKey::Session(_) => "session:*",
}
}
}
impl ToRedisArgs for CacheKey<'_> {
fn write_redis_args<W>(&self, out: &mut W)
where
W: ?Sized + redis::RedisWrite,
{
out.write_arg_fmt(match self {
CacheKey::Session(id) => format!("session:{id}"),
})
}
}
impl ToSingleRedisArg for CacheKey<'_> {}
|