pub struct LiquidCacheBuilder { /* private fields */ }Expand description
Builder for LiquidCache.
Example:
use liquid_cache::cache::LiquidCacheBuilder;
use liquid_cache::cache_policies::LiquidPolicy;
tokio_test::block_on(async {
let _storage = LiquidCacheBuilder::new()
.with_batch_size(8192)
.with_max_memory_bytes(1024 * 1024 * 1024)
.with_cache_policy(Box::new(LiquidPolicy::new()))
.build()
.await;
});Implementations§
Source§impl LiquidCacheBuilder
impl LiquidCacheBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new instance of LiquidCacheBuilder.
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_memory_bytes(self, max_memory_bytes: usize) -> Self
pub fn with_max_memory_bytes(self, max_memory_bytes: usize) -> Self
Set the max memory bytes for the cache. Default is 1GB.
Sourcepub fn with_max_disk_bytes(self, max_disk_bytes: usize) -> Self
pub fn with_max_disk_bytes(self, max_disk_bytes: usize) -> Self
Set the max disk bytes for the cache. Default is unlimited.
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_metadata(self, metadata: Arc<dyn EntryMetadata>) -> Self
pub fn with_metadata(self, metadata: Arc<dyn EntryMetadata>) -> Self
Set the EntryMetadata for the cache. Default is DefaultCacheMetadata.
Sourcepub fn with_store(self, store: Store) -> Self
pub fn with_store(self, store: Store) -> Self
Set the t4::Store used for on-disk IO.
If not provided, the builder mounts a fresh store at a temporary directory.
Sourcepub fn with_squeeze_victims_concurrently(self, enabled: bool) -> Self
pub fn with_squeeze_victims_concurrently(self, enabled: bool) -> Self
Set whether cache victims are squeezed concurrently.
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