Skip to main content

CacheConfig

Struct CacheConfig 

Source
#[non_exhaustive]
pub struct CacheConfig { pub memory_bytes: usize, pub disk: Option<DiskCache>, pub memory_auto: Option<MemoryPolicy>, pub write_queue_bytes: usize, pub writers: Option<usize>, }
Expand description

Cache configuration for an Engine.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§memory_bytes: usize

In-memory LRU capacity for inflated entries (0 disables it).

§disk: Option<DiskCache>

On-disk cache shared across processes.

§memory_auto: Option<MemoryPolicy>

Treat memory_bytes as a starting point and keep resizing the LRU to this process’s share of one budget for every resident host the user runs (MemoryPolicy::share), instead of a fixed capacity.

§write_queue_bytes: usize

Heap queued disk writes may hold before new ones are deferred (an L1 entry is inflated again when its turn comes, L2 tables are dropped); a memory cache’s budget lowers it further.

§writers: Option<usize>

Disk writer threads (None: CacheConfig::auto_writers).

Implementations§

Source§

impl CacheConfig

Source

pub fn memory_bytes(self, memory_bytes: usize) -> Self

The configuration with memory_bytes set.

Source

pub fn disk(self, disk: Option<DiskCache>) -> Self

The configuration with disk set.

Source

pub fn memory_auto(self, memory_auto: Option<MemoryPolicy>) -> Self

The configuration with memory_auto set.

Source

pub fn write_queue_bytes(self, write_queue_bytes: usize) -> Self

The configuration with write_queue_bytes set.

Source

pub fn writers(self, writers: Option<usize>) -> Self

The configuration with writers set.

Source§

impl CacheConfig

Source

pub const WRITE_QUEUE: usize

Default of CacheConfig::write_queue_bytes. A cold multi-APK sweep inflates far faster than the writers persist, and each queued job keeps its DEX bytes or tables alive until written; without a bound the heap grows with the backlog (tens of GB over a phone’s APKs).

Source

pub const MAX_AUTO_WRITERS: usize = 4

Most automatic writer threads: writing is I/O, but a deferred L1 write inflates its entry again first.

Source

pub fn disk_default() -> CacheConfig

Disk cache in the default directory, no in-memory cache (CLI default).

Source

pub fn resident(memory_bytes: usize) -> CacheConfig

Disk cache plus an in-memory LRU of a fixed capacity.

Source

pub fn auto_writers(cpus: usize) -> usize

One writer per 8 CPUs, 1..=CacheConfig::MAX_AUTO_WRITERS.

Trait Implementations§

Source§

impl Default for CacheConfig

Source§

fn default() -> CacheConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.