Cache

Trait Cache 

Source
pub trait Cache<K, V>: Send + Sync
where K: Hash + Eq + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,
{ // Required methods fn get(&self, key: &K) -> Option<V>; fn put(&mut self, key: K, value: V) -> RragResult<()>; fn remove(&mut self, key: &K) -> Option<V>; fn contains(&self, key: &K) -> bool; fn clear(&mut self); fn size(&self) -> usize; fn stats(&self) -> CacheStats; }
Expand description

Generic cache trait

Required Methods§

Source

fn get(&self, key: &K) -> Option<V>

Get value from cache

Source

fn put(&mut self, key: K, value: V) -> RragResult<()>

Put value into cache

Source

fn remove(&mut self, key: &K) -> Option<V>

Remove value from cache

Source

fn contains(&self, key: &K) -> bool

Check if key exists

Source

fn clear(&mut self)

Clear all entries

Source

fn size(&self) -> usize

Get cache size

Source

fn stats(&self) -> CacheStats

Get cache statistics

Implementors§

Source§

impl Cache<String, EmbeddingCacheEntry> for EmbeddingCache

Source§

impl Cache<String, QueryCacheEntry> for QueryCache

Source§

impl Cache<String, ResultCacheEntry> for ResultCache

Source§

impl Cache<String, SemanticCacheEntry> for SemanticCache

Source§

impl<K, V> Cache<K, V> for LFUCache<K, V>
where K: Hash + Eq + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,

Source§

impl<K, V> Cache<K, V> for LRUCache<K, V>
where K: Hash + Eq + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,

Source§

impl<K, V> Cache<K, V> for TTLCache<K, V>
where K: Hash + Eq + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,