Skip to content

Commit

Permalink
RUN-616: Use CountBytes trait in LruCache
Browse files Browse the repository at this point in the history
  • Loading branch information
berestovskyy committed Apr 14, 2023
1 parent 05ebed0 commit 00b5005
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 73 deletions.
6 changes: 3 additions & 3 deletions rs/execution_environment/src/query_handler/query_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl CountBytes for QueryCache {
impl Default for QueryCache {
fn default() -> Self {
QueryCache {
cache: Mutex::new(LruCache::new((u64::MAX / 2).into())),
cache: Mutex::new(LruCache::unbounded()),
}
}
}
Expand All @@ -134,14 +134,14 @@ impl QueryCache {
if value.is_valid(env) {
return Some(value.result());
} else {
// Remove the invalid entry.
cache.pop(key);
}
}
None
}

pub(crate) fn insert(&self, key: EntryKey, value: EntryValue) {
let size = (key.count_bytes() + value.count_bytes()) as u64;
self.cache.lock().unwrap().put(key, value, size.into());
self.cache.lock().unwrap().push(key, value);
}
}
2 changes: 1 addition & 1 deletion rs/utils/lru_cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2021"

[dependencies]
ic-types = { path = "../../types/types" }
lru = { version = "0.7.1", default-features = false }
lru = { version = "0.7.1", default-features = false }
Loading

0 comments on commit 00b5005

Please sign in to comment.