1use std::collections::HashMap;
6
7#[derive(Debug, Clone)]
9pub struct CacheEntry {
10 pub hash: String,
11 pub bytecode: Vec<u8>,
12 pub timestamp: u64,
13}
14
15#[derive(Default)]
17pub struct CompilationCache {
18 entries: HashMap<String, CacheEntry>,
19}
20
21impl CompilationCache {
22 pub fn new() -> Self {
23 Self::default()
24 }
25
26 pub fn get(&self, key: &str) -> Option<&CacheEntry> {
27 self.entries.get(key)
28 }
29
30 pub fn insert(&mut self, key: String, entry: CacheEntry) {
31 self.entries.insert(key, entry);
32 }
33
34 pub fn invalidate(&mut self, key: &str) {
35 self.entries.remove(key);
36 }
37
38 pub fn clear(&mut self) {
39 self.entries.clear();
40 }
41}