Skip to main content

CachePolicy

Struct CachePolicy 

Source
pub struct CachePolicy {
    pub enabled: bool,
    pub ttl: Option<Duration>,
    pub tier_hint: Option<CacheTier>,
    pub bypass: bool,
    pub invalidation_hint: Option<InvalidationHint>,
}
Expand description

Policy controlling how a Query result is cached. Carried in Context and optionally overridden on Query.cache_policy.

Fields§

§enabled: bool

If false, do not read from or write to any cache tier.

§ttl: Option<Duration>

Explicit time-to-live; None means ‘defer to tier default’.

§tier_hint: Option<CacheTier>

Preferred tier for this query; None means ‘tier decides’.

§bypass: bool

If true, skip cache read but still write-through on miss.

§invalidation_hint: Option<InvalidationHint>

Optional hint to the cache about when to invalidate.

Implementations§

Source§

impl CachePolicy

Source

pub fn new() -> Self

Construct a default policy: enabled, no TTL, no tier hint, no bypass, no invalidation hint.

Source

pub fn disabled() -> Self

Disable all caching for this query.

Source

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

Set the TTL.

Source

pub fn with_tier(self, tier: CacheTier) -> Self

Set the tier hint.

Source

pub fn with_bypass(self, bypass: bool) -> Self

Set the bypass flag.

Trait Implementations§

Source§

impl Clone for CachePolicy

Source§

fn clone(&self) -> CachePolicy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CachePolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CachePolicy

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for CachePolicy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CachePolicy

Source§

fn eq(&self, other: &CachePolicy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for CachePolicy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CachePolicy

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.