Skip to main content

CacheBuilderInstance

Struct CacheBuilderInstance 

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

Represents a particular instance of a CacheBuilder. It includes extra metadata of the policy, required to successfully work in all scenarios involving multiple policies.

Implementations§

Source§

impl CacheBuilderInstance

Source

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

Sets the maximum number of entries available for the cache.

Source

pub fn shared(self) -> Self

Indicates that the cache should not be isolated to the policy. The state will be shared across different policy instances and different policies that use the same cache ID.

Source

pub fn eviction_strategy(self, strategy: EvictionStrategy) -> Self

Sets the eviction strategy for this specific cache instance. This overrides the strategy set on the builder.

Source

pub fn ttl(self, ttl: Duration) -> Self

Sets the time-to-live for cached entries. After this duration, entries expire and are lazily removed on the next read.

Note: When using shared caches, all policy instances sharing the cache ID must use the same TTL setting. A cache with TTL enabled serializes values with a TTL envelope; a cache without TTL (or reading with a different encoding) will fail to deserialize the entry and treat it as a cache miss.

Source

pub fn build(self) -> impl Cache + 'static

Builds a new Cache with the corresponding specifications.

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<C, T> Extract<T> for C
where T: FromContext<C>,

Source§

type Error = <T as FromContext<C>>::Error

Source§

fn extract(&self) -> Result<T, <C as Extract<T>>::Error>

Source§

fn extract_always(&self) -> T
where Self: Extract<T, Error = !>,

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.