1#[derive(Debug, Clone)]
3pub struct RedisConfig {
4 pub url: String,
6 pub pool_size: usize,
8 pub key_prefix: String,
10 pub dedup_ttl: u64,
12}
13
14impl Default for RedisConfig {
15 fn default() -> Self {
16 Self {
17 url: "redis://127.0.0.1:6379".to_string(),
18 pool_size: 10,
19 key_prefix: "kojin".to_string(),
20 dedup_ttl: 300,
21 }
22 }
23}
24
25impl RedisConfig {
26 pub fn new(url: impl Into<String>) -> Self {
27 Self {
28 url: url.into(),
29 ..Default::default()
30 }
31 }
32
33 pub fn with_pool_size(mut self, size: usize) -> Self {
34 self.pool_size = size;
35 self
36 }
37
38 pub fn with_prefix(mut self, prefix: impl Into<String>) -> Self {
39 self.key_prefix = prefix.into();
40 self
41 }
42
43 pub fn with_dedup_ttl(mut self, seconds: u64) -> Self {
44 self.dedup_ttl = seconds;
45 self
46 }
47}