Skip to main content

Cache

Struct Cache 

Source
pub struct Cache { /* private fields */ }
Expand description

Cache, in which blocks or blobs are cached in-memory after being retrieved from disk

This speeds up consecutive queries to nearby data, improving read performance for hot data.

§Examples

Sharing cache between multiple trees

// Provide 64 MB of cache capacity
let cache = Arc::new(Cache::with_capacity_bytes(64 * 1_000 * 1_000));

let tree1 = Config::new(folder, Default::default(), Default::default()).use_cache(cache.clone()).open()?;
let tree2 = Config::new(folder, Default::default(), Default::default()).use_cache(cache.clone()).open()?;

Implementations§

Source§

impl Cache

Source

pub fn with_capacity_bytes(bytes: u64) -> Self

Creates a new block cache with roughly n bytes of capacity.

Source

pub fn with_row_cache(self, enabled: bool) -> Self

Enables or disables the row cache (decoded point-read results), returning the cache for builder-style configuration. Off by default; rows share the block cache’s byte capacity when enabled.

Source

pub fn row_cache_enabled(&self) -> bool

Whether the row cache is enabled (see Cache::with_row_cache).

Source

pub fn with_metadata_priority(self, enabled: bool) -> Self

Enables or disables high-priority pinning of index / filter / range-tombstone blocks (see Cache::metadata_priority field docs), returning the cache for builder-style configuration. On by default.

Source

pub fn metadata_priority(&self) -> bool

Whether metadata-block priority pinning is enabled (see Cache::with_metadata_priority).

Source

pub fn size(&self) -> u64

Returns the amount of cached bytes.

Source

pub fn capacity(&self) -> u64

Returns the cache capacity in bytes.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Cache

§

impl Freeze for Cache

§

impl Send for Cache

§

impl Sync for Cache

§

impl Unpin for Cache

§

impl UnsafeUnpin for Cache

§

impl UnwindSafe for Cache

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V