use crate::config::runtime::RuntimeOptions;
use crate::region::recovery::DataGeometry;
pub mod runtime;
pub mod storage;
#[derive(Clone, Debug)]
pub struct CacheConfig {
storage: StorageLayout,
runtime: RuntimeOptions,
l1_entry_capacity: usize,
reserved_memory_bytes: usize,
minimum_memory_bytes: usize,
}
impl CacheConfig {
pub const fn storage(&self) -> &StorageLayout {
&self.storage
}
pub const fn runtime(&self) -> &RuntimeOptions {
&self.runtime
}
pub const fn minimum_memory_bytes(&self) -> usize {
self.minimum_memory_bytes
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct StorageLayout {
geometry: DataGeometry,
index_slots: usize,
fingerprint: u64,
peak_disk_bytes: u64,
}
impl StorageLayout {
pub const fn capacity_bytes(&self) -> u64 {
self.geometry.region_size * self.geometry.region_count as u64
}
pub const fn region_size_bytes(&self) -> u64 {
self.geometry.region_size
}
pub const fn region_count(&self) -> u32 {
self.geometry.region_count
}
pub const fn index_slots(&self) -> usize {
self.index_slots
}
pub const fn peak_disk_bytes(&self) -> u64 {
self.peak_disk_bytes
}
}
pub const fn storage_geometry(storage: &StorageLayout) -> DataGeometry {
storage.geometry
}
pub const fn storage_fingerprint(storage: &StorageLayout) -> u64 {
storage.fingerprint
}
pub const fn l1_entry_capacity(config: &CacheConfig) -> usize {
config.l1_entry_capacity
}
pub const fn reserved_memory_bytes(config: &CacheConfig) -> usize {
config.reserved_memory_bytes
}