oxirs_embed/contextual/
context_cache.rs1use super::{ContextCacheConfig, ProcessedContext};
4use crate::{Triple, Vector};
5use std::collections::HashMap;
6
7pub struct ContextCache {
9 config: ContextCacheConfig,
10 cache: HashMap<String, CacheEntry>,
11 stats: CacheStats,
12}
13
14impl ContextCache {
15 pub fn new(config: ContextCacheConfig) -> Self {
16 Self {
17 config,
18 cache: HashMap::new(),
19 stats: CacheStats::default(),
20 }
21 }
22
23 pub async fn get_embeddings(
24 &self,
25 _triples: &[Triple],
26 _context: &ProcessedContext,
27 ) -> Option<Vec<Vector>> {
28 None }
30
31 pub async fn store_embeddings(
32 &mut self,
33 _triples: &[Triple],
34 _context: &ProcessedContext,
35 _embeddings: &[Vector],
36 ) {
37 }
39}
40
41#[derive(Debug, Clone)]
43struct CacheEntry {
44 embeddings: Vec<Vector>,
45 timestamp: std::time::Instant,
46 access_count: u32,
47}
48
49#[derive(Debug, Default)]
51pub struct CacheStats {
52 pub hits: u64,
53 pub misses: u64,
54 pub evictions: u64,
55 pub size: usize,
56}