use std::sync::Arc;
use apl_cpex::{SessionStore, SessionStoreFactory};
use crate::config::ValkeyConfig;
use crate::store::ValkeySessionStore;
pub const KIND: &str = "valkey";
#[derive(Default)]
pub struct ValkeySessionStoreFactory;
impl ValkeySessionStoreFactory {
pub fn new() -> Self {
Self
}
}
impl SessionStoreFactory for ValkeySessionStoreFactory {
fn kind(&self) -> &str {
KIND
}
fn build(
&self,
config: &serde_yaml::Value,
) -> Result<Arc<dyn SessionStore>, Box<dyn std::error::Error + Send + Sync>> {
let cfg = ValkeyConfig::from_value(config)?;
let store = ValkeySessionStore::from_config(&cfg)?;
Ok(Arc::new(store))
}
}