pub struct CommandCacheConfig { /* private fields */ }
Expand description
CommandCacheConfig is used to define caching behaviour of individual commands.
§Example
use std::time::Duration;
use redis::{CommandCacheConfig, Cmd};
let ttl = Duration::from_secs(120); // 2 minutes TTL
let config = CommandCacheConfig::new()
.set_enable_cache(true)
.set_client_side_ttl(ttl);
let command = Cmd::new().arg("GET").arg("key").set_cache_config(config);
Implementations§
Source§impl CommandCacheConfig
impl CommandCacheConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates new CommandCacheConfig with enable_cache as true and without client_side_ttl.
Sourcepub fn set_enable_cache(self, enable_cache: bool) -> Self
pub fn set_enable_cache(self, enable_cache: bool) -> Self
Sets whether the cache should be enabled or not. Disabling cache for specific command when using crate::caching::CacheMode::All will not work.
Sourcepub fn set_client_side_ttl(self, client_side_ttl: Duration) -> Self
pub fn set_client_side_ttl(self, client_side_ttl: Duration) -> Self
Sets custom client side time to live (TTL).
Trait Implementations§
Source§impl Clone for CommandCacheConfig
impl Clone for CommandCacheConfig
Source§fn clone(&self) -> CommandCacheConfig
fn clone(&self) -> CommandCacheConfig
Returns a copy 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 moreAuto Trait Implementations§
impl Freeze for CommandCacheConfig
impl RefUnwindSafe for CommandCacheConfig
impl Send for CommandCacheConfig
impl Sync for CommandCacheConfig
impl Unpin for CommandCacheConfig
impl UnwindSafe for CommandCacheConfig
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