use crate::domain::types::Finding;
use crate::ports::outbound::AnalysisCache;
use std::collections::HashMap;
use std::sync::Mutex;
#[derive(Default)]
pub struct MemoryCache {
inner: Mutex<HashMap<String, Vec<Finding>>>,
}
impl AnalysisCache for MemoryCache {
fn get(&self, key: &str) -> Option<Vec<Finding>> {
self.inner.lock().ok()?.get(key).cloned()
}
fn put(&self, key: &str, findings: &[Finding]) {
if let Ok(mut g) = self.inner.lock() {
g.insert(key.to_string(), findings.to_vec());
}
}
}