pub struct CacheOptions {
pub ttl: Option<Duration>,
pub policy: CachePolicy,
pub write_policy: WritePolicy,
pub tags: Vec<EntityTag>,
pub max_size: Option<usize>,
pub cache_empty: bool,
pub bypass: bool,
pub stale_while_revalidate: Option<Duration>,
}Expand description
Options for caching a query result.
Fields§
§ttl: Option<Duration>Time-to-live for the cached entry.
policy: CachePolicyCache policy to use.
write_policy: WritePolicyWrite policy (when to write to cache).
Tags for invalidation.
max_size: Option<usize>Skip caching if result is larger than this size (bytes).
cache_empty: boolWhether to cache empty results.
bypass: boolWhether to bypass cache for this query.
stale_while_revalidate: Option<Duration>Stale-while-revalidate duration.
Implementations§
Source§impl CacheOptions
impl CacheOptions
Sourcepub fn with_policy(self, policy: CachePolicy) -> Self
pub fn with_policy(self, policy: CachePolicy) -> Self
Set the cache policy.
Sourcepub fn with_write_policy(self, policy: WritePolicy) -> Self
pub fn with_write_policy(self, policy: WritePolicy) -> Self
Set the write policy.
Add multiple tags.
Sourcepub fn with_max_size(self, size: usize) -> Self
pub fn with_max_size(self, size: usize) -> Self
Set max size.
Sourcepub fn no_size_limit(self) -> Self
pub fn no_size_limit(self) -> Self
Don’t limit size.
Sourcepub fn no_cache_empty(self) -> Self
pub fn no_cache_empty(self) -> Self
Don’t cache empty results.
Sourcepub fn stale_while_revalidate(self, duration: Duration) -> Self
pub fn stale_while_revalidate(self, duration: Duration) -> Self
Enable stale-while-revalidate.
Trait Implementations§
Source§impl Clone for CacheOptions
impl Clone for CacheOptions
Source§fn clone(&self) -> CacheOptions
fn clone(&self) -> CacheOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CacheOptions
impl Debug for CacheOptions
Auto Trait Implementations§
impl Freeze for CacheOptions
impl RefUnwindSafe for CacheOptions
impl Send for CacheOptions
impl Sync for CacheOptions
impl Unpin for CacheOptions
impl UnwindSafe for CacheOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more