pub struct FeOxDbBackend<S = JsonFormat, C = PassthroughCompressor>where
S: Format,
C: Compressor,{ /* private fields */ }Expand description
Disk-based cache backend using FeOxDB.
Use this when cache data must survive restarts or doesn’t fit in memory.
For pure speed without persistence, prefer MokaBackend.
use hitbox_feoxdb::FeOxDbBackend;
// Persistent cache with defaults
let backend = FeOxDbBackend::builder()
.path("/var/cache/myapp")
.build()?;
// With resource limits
let backend = FeOxDbBackend::builder()
.path("/var/cache/myapp")
.max_file_size(10 * 1024 * 1024 * 1024) // 10 GB
.max_memory(256 * 1024 * 1024) // 256 MB
.build()?;Cloning is cheap — clones share the same underlying database.
Implementations§
Source§impl<S, C> FeOxDbBackend<S, C>where
S: Format,
C: Compressor,
impl<S, C> FeOxDbBackend<S, C>where
S: Format,
C: Compressor,
Source§impl FeOxDbBackend<JsonFormat, PassthroughCompressor>
impl FeOxDbBackend<JsonFormat, PassthroughCompressor>
Sourcepub fn builder() -> FeOxDbBackendBuilder<JsonFormat, PassthroughCompressor>
pub fn builder() -> FeOxDbBackendBuilder<JsonFormat, PassthroughCompressor>
Starts building a new backend.
Sourcepub fn in_memory() -> Result<Self, FeOxDbError>
pub fn in_memory() -> Result<Self, FeOxDbError>
In-memory backend for tests.
Data is lost when dropped. Equivalent to builder().build().
use hitbox_feoxdb::FeOxDbBackend;
let backend = FeOxDbBackend::in_memory()
.expect("Failed to create in-memory backend");Trait Implementations§
Source§impl<S, C> Backend for FeOxDbBackend<S, C>
impl<S, C> Backend for FeOxDbBackend<S, C>
Source§fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<CacheValue<Raw>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = BackendResult<Option<CacheValue<Raw>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read raw cached data by key. Read more
Source§fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
value: CacheValue<Raw>,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
value: CacheValue<Raw>,
) -> Pin<Box<dyn Future<Output = BackendResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Write raw data to cache.
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = BackendResult<DeleteStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = BackendResult<DeleteStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove data from cache.
Source§fn value_format(&self) -> &dyn Format
fn value_format(&self) -> &dyn Format
Serialization format for cached values. Default:
BincodeFormat.Source§fn key_format(&self) -> &CacheKeyFormat
fn key_format(&self) -> &CacheKeyFormat
Key serialization format. Default:
CacheKeyFormat::Bitcode.Source§fn compressor(&self) -> &dyn Compressor
fn compressor(&self) -> &dyn Compressor
Compressor for cached values. Default:
PassthroughCompressor.Source§fn label(&self) -> BackendLabel
fn label(&self) -> BackendLabel
Backend label for metrics and source path composition. Read more
Source§impl<S, C> CacheBackend for FeOxDbBackend<S, C>
impl<S, C> CacheBackend for FeOxDbBackend<S, C>
Source§fn get<T>(
&self,
key: &CacheKey,
ctx: &mut SmallBox<dyn Context, S4>,
) -> impl Future<Output = Result<Option<CacheValue<<T as CacheableResponse>::Cached>>, BackendError>> + Send
fn get<T>( &self, key: &CacheKey, ctx: &mut SmallBox<dyn Context, S4>, ) -> impl Future<Output = Result<Option<CacheValue<<T as CacheableResponse>::Cached>>, BackendError>> + Send
Retrieve a typed value from cache. Read more
Source§impl<S, C> Clone for FeOxDbBackend<S, C>
impl<S, C> Clone for FeOxDbBackend<S, C>
Source§fn clone(&self) -> FeOxDbBackend<S, C>
fn clone(&self) -> FeOxDbBackend<S, C>
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 moreAuto Trait Implementations§
impl<S, C> Freeze for FeOxDbBackend<S, C>
impl<S = JsonFormat, C = PassthroughCompressor> !RefUnwindSafe for FeOxDbBackend<S, C>
impl<S, C> Send for FeOxDbBackend<S, C>
impl<S, C> Sync for FeOxDbBackend<S, C>
impl<S, C> Unpin for FeOxDbBackend<S, C>
impl<S = JsonFormat, C = PassthroughCompressor> !UnwindSafe for FeOxDbBackend<S, C>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Compose for Twhere
T: Backend,
impl<T> Compose for Twhere
T: Backend,
Source§fn compose<L2, O>(self, l2: L2, offload: O) -> CompositionBackend<Self, L2, O>
fn compose<L2, O>(self, l2: L2, offload: O) -> CompositionBackend<Self, L2, O>
Compose this backend with another backend as L2, using default policies. Read more
Source§fn compose_with<L2, O, R, W>(
self,
l2: L2,
offload: O,
policy: CompositionPolicy<R, W>,
) -> CompositionBackend<Self, L2, O, R, W>
fn compose_with<L2, O, R, W>( self, l2: L2, offload: O, policy: CompositionPolicy<R, W>, ) -> CompositionBackend<Self, L2, O, R, W>
Compose this backend with another backend as L2, using custom policies. Read more