pub trait Cache: Send + Sync {
// Required methods
fn get(&self, key: &str) -> Option<Vec<u8>>;
fn set(&self, key: &str, value: &[u8]) -> Result<(), AnalysisError>;
fn invalidate(&self, key: &str) -> Result<(), AnalysisError>;
fn clear(&self) -> Result<(), AnalysisError>;
}Expand description
Cache operations trait.
This trait abstracts over caching mechanisms, enabling:
- Testing without persistent storage
- Different cache backends (memory, disk, distributed)
- Cache invalidation strategies
§Serialization
Cache values must be serializable. The default implementation uses bincode for efficient binary serialization.
Required Methods§
Sourcefn get(&self, key: &str) -> Option<Vec<u8>>
fn get(&self, key: &str) -> Option<Vec<u8>>
Get a cached value by key.
Returns None if the key doesn’t exist or the value can’t be
deserialized to the requested type.