Skip to content

Commit

Permalink
Simplify a little the cache when possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuDutSik committed Sep 24, 2024
1 parent 0bed463 commit ace1633
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ A Byzantine-fault tolerant sidechain with low-latency finality and high throughp
* `--max-stream-queries <MAX_STREAM_QUERIES>` — The maximal number of simultaneous stream queries to the database

Default value: `10`
* `--max-cache-size <MAX_CACHE_SIZE>` — The maximal size of the storage cache
* `--max-cache-size <MAX_CACHE_SIZE>` — The maximal size of the storage cache, in bytes

Default value: `10000000`
* `--max-cache-entries <MAX_CACHE_ENTRIES>` — The maximal number of entries in the storage cache
Expand Down
14 changes: 13 additions & 1 deletion linera-views/src/backends/lru_caching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ impl LruPrefixCache {
// which is counter productive
return;
}
let full_prefix = (key_prefix.clone(), CacheEntry::Find);
let keys = self
.map_find
.range(get_interval(key_prefix.clone()))
Expand All @@ -503,6 +502,19 @@ impl LruPrefixCache {
let full_key = (key, CacheEntry::Find);
self.remove_from_queue(&full_key);
}
if let FindCacheEntry::KeyValues(_) = cache_entry {
let keys = self
.map_value
.range(get_interval(key_prefix.clone()))
.map(|(x,_)| x.clone())
.collect::<Vec<_>>();
for key in keys {
self.map_value.remove(&key);
let full_key = (key, CacheEntry::Value);
self.remove_from_queue(&full_key);
}
}
let full_prefix = (key_prefix.clone(), CacheEntry::Find);
match self.map_find.entry(key_prefix.clone()) {
btree_map::Entry::Occupied(mut entry) => {
entry.insert(cache_entry);
Expand Down

0 comments on commit ace1633

Please sign in to comment.