From e249776a105f7c036e03380ee873f1410ee29d68 Mon Sep 17 00:00:00 2001 From: Andrew Morris Date: Thu, 29 Feb 2024 10:04:13 +1100 Subject: [PATCH] Clear read cache --- storage/src/storage.rs | 4 ++++ vstc/src/db_host.rs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/storage/src/storage.rs b/storage/src/storage.rs index 941d013..ab64403 100644 --- a/storage/src/storage.rs +++ b/storage/src/storage.rs @@ -35,6 +35,10 @@ impl Storage { .transaction_mut(Rc::downgrade(&self.sb), |sb| sb.remove_head(ptr)) } + pub fn clear_read_cache(&mut self) { + self.sb.borrow_mut().get_read_cache().clear() + } + pub fn store_tmp>( &mut self, value: &SE, diff --git a/vstc/src/db_host.rs b/vstc/src/db_host.rs index 7932db5..5080edc 100644 --- a/vstc/src/db_host.rs +++ b/vstc/src/db_host.rs @@ -107,7 +107,6 @@ impl DbActor { Self { storage, apply_fn: inline_valuescript( - // TODO: store in actor r#" export default function(req) { if ("handleRequest" in this) { @@ -197,6 +196,9 @@ impl Handler for DbActor { .set_head(storage_head_ptr(b"state"), &instance) .unwrap(); + // TODO: Consider more cache retention + self.storage.clear_read_cache(); + res } }