1use crate::store::CacheStore;
2use std::{collections::HashMap, sync::Arc};
3
4pub struct CacheRegistry {
5 stores: HashMap<String, Arc<dyn CacheStore>>,
6}
7
8impl CacheRegistry {
9 pub fn new() -> Self {
10 Self {
11 stores: HashMap::new(),
12 }
13 }
14
15 pub fn add(&mut self, name: impl Into<String>, store: Arc<dyn CacheStore>) {
16 self.stores.insert(name.into(), store);
17 }
18
19 pub fn store(&self, name: &str) -> Option<Arc<dyn CacheStore>> {
20 self.stores.get(name).cloned()
21 }
22}
23
24impl Default for CacheRegistry {
25 fn default() -> Self {
26 Self::new()
27 }
28}