pub struct LiquidCacheBuilder { /* private fields */ }Expand description
Builder for LiquidCache.
Example:
use liquid_cache::cache::LiquidCacheBuilder;
use liquid_cache::cache_policies::LiquidPolicy;
let _storage = LiquidCacheBuilder::new()
.with_batch_size(8192)
.with_max_cache_bytes(1024 * 1024 * 1024)
.with_cache_policy(Box::new(LiquidPolicy::new()))
.build();Implementations§
Source§impl LiquidCacheBuilder
impl LiquidCacheBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new instance of LiquidCacheBuilder.
Sourcepub fn with_cache_dir(self, cache_dir: PathBuf) -> Self
pub fn with_cache_dir(self, cache_dir: PathBuf) -> Self
Set the cache directory for the cache. Default is a temporary directory.
Sourcepub fn with_batch_size(self, batch_size: usize) -> Self
pub fn with_batch_size(self, batch_size: usize) -> Self
Set the batch size for the cache. Default is 8192.
Sourcepub fn with_max_cache_bytes(self, max_cache_bytes: usize) -> Self
pub fn with_max_cache_bytes(self, max_cache_bytes: usize) -> Self
Set the max cache bytes for the cache. Default is 1GB.
Sourcepub fn with_cache_policy(self, policy: Box<dyn CachePolicy>) -> Self
pub fn with_cache_policy(self, policy: Box<dyn CachePolicy>) -> Self
Set the cache policy for the cache. Default is LiquidPolicy.
Sourcepub fn with_hydration_policy(self, policy: Box<dyn HydrationPolicy>) -> Self
pub fn with_hydration_policy(self, policy: Box<dyn HydrationPolicy>) -> Self
Set the hydration policy for the cache. Default is crate::cache::NoHydration.
Sourcepub fn with_squeeze_policy(self, policy: Box<dyn SqueezePolicy>) -> Self
pub fn with_squeeze_policy(self, policy: Box<dyn SqueezePolicy>) -> Self
Set the squeeze policy for the cache. Default is TranscodeSqueezeEvict.
Sourcepub fn with_io_context(self, io_context: Arc<dyn IoContext>) -> Self
pub fn with_io_context(self, io_context: Arc<dyn IoContext>) -> Self
Set the IoContext for the cache. Default is DefaultIoContext.
Sourcepub fn build(self) -> Arc<LiquidCache>
pub fn build(self) -> Arc<LiquidCache>
Build the cache storage.
The cache storage is wrapped in an Arc to allow for concurrent access.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LiquidCacheBuilder
impl !RefUnwindSafe for LiquidCacheBuilder
impl Send for LiquidCacheBuilder
impl Sync for LiquidCacheBuilder
impl Unpin for LiquidCacheBuilder
impl UnsafeUnpin for LiquidCacheBuilder
impl !UnwindSafe for LiquidCacheBuilder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request