add ability to flush read only accounts cache (#28726)
This commit is contained in:
parent
faf32e2a94
commit
88d7f6cc9d
|
@ -5260,6 +5260,12 @@ impl AccountsDb {
|
|||
)
|
||||
}
|
||||
|
||||
/// remove all entries from the read only accounts cache
|
||||
/// useful for benches/tests
|
||||
pub fn flush_read_only_cache_for_tests(&self) {
|
||||
self.read_only_accounts_cache.reset_for_tests();
|
||||
}
|
||||
|
||||
/// if 'load_into_read_cache_only', then return value is meaningless.
|
||||
/// The goal is to get the account into the read-only cache.
|
||||
fn do_load_with_populate_read_cache(
|
||||
|
|
|
@ -54,6 +54,17 @@ impl ReadOnlyAccountsCache {
|
|||
}
|
||||
}
|
||||
|
||||
/// reset the read only accounts cache
|
||||
/// useful for benches/tests
|
||||
pub fn reset_for_tests(&self) {
|
||||
self.cache.clear();
|
||||
self.queue.lock().unwrap().clear();
|
||||
self.data_size.store(0, Ordering::Relaxed);
|
||||
self.hits.store(0, Ordering::Relaxed);
|
||||
self.misses.store(0, Ordering::Relaxed);
|
||||
self.evicts.store(0, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// true if pubkey is in cache at slot
|
||||
pub fn in_cache(&self, pubkey: &Pubkey, slot: Slot) -> bool {
|
||||
self.cache.contains_key(&(*pubkey, slot))
|
||||
|
|
Loading…
Reference in New Issue