From e4e35bc7ced49f57bf78fa9ddbc0dc4a218d0501 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Mon, 8 Jan 2024 11:12:34 +0100 Subject: [PATCH] Rollup node/store: cache value on read This is useful if we never write to the singleton store. --- src/lib_layer2_store/indexed_store.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib_layer2_store/indexed_store.ml b/src/lib_layer2_store/indexed_store.ml index 8f915393464d..1d5a818123bb 100644 --- a/src/lib_layer2_store/indexed_store.ml +++ b/src/lib_layer2_store/indexed_store.ml @@ -646,7 +646,12 @@ end) : SINGLETON_STORE with type value := S.t = struct let read store = let open Lwt_result_syntax in - match store.cache with Some v -> return v | None -> read_disk store + match store.cache with + | Some v -> return v + | None -> + let* value = read_disk store in + store.cache <- Some value ; + return value let write_disk store x = let open Lwt_result_syntax in -- GitLab