pub struct CacheStorageBuilder { /* private fields */ }Expand description
Builder for CacheStorage.
Example:
use liquid_cache_storage::cache::CacheStorageBuilder;
use liquid_cache_storage::cache_policies::LiquidPolicy;
let _storage = CacheStorageBuilder::new()
.with_batch_size(8192)
.with_max_cache_bytes(1024 * 1024 * 1024)
.with_cache_policy(Box::new(LiquidPolicy::new()))
.build();Implementations§
Source§impl CacheStorageBuilder
impl CacheStorageBuilder
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_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_worker(self, io_worker: Arc<dyn IoContext>) -> Self
pub fn with_io_worker(self, io_worker: Arc<dyn IoContext>) -> Self
Set the io worker for the cache. Default is DefaultIoContext.
Sourcepub fn build(self) -> Arc<CacheStorage>
pub fn build(self) -> Arc<CacheStorage>
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 CacheStorageBuilder
impl !RefUnwindSafe for CacheStorageBuilder
impl Send for CacheStorageBuilder
impl Sync for CacheStorageBuilder
impl Unpin for CacheStorageBuilder
impl !UnwindSafe for CacheStorageBuilder
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