value_log/
blob_cache.rs

1// Copyright (c) 2024-present, fjall-rs
2// This source code is licensed under both the Apache 2.0 and MIT License
3// (found in the LICENSE-* files in the repository)
4
5use crate::{value_log::ValueLogId, UserValue, ValueHandle};
6
7/// Blob cache, in which blobs are cached in-memory
8/// after being retrieved from disk
9///
10/// This speeds up consecutive accesses to the same blobs, improving
11/// read performance for hot data.
12pub trait BlobCache: Clone {
13    /// Caches a blob.
14    fn insert(&self, vlog_id: ValueLogId, vhandle: &ValueHandle, value: UserValue);
15
16    /// Retrieves a blob from the cache, or `None` if it could not be found.
17    fn get(&self, vlog_id: ValueLogId, vhandle: &ValueHandle) -> Option<UserValue>;
18}