Struct opendal::layers::ContentCacheLayer
source · pub struct ContentCacheLayer { /* private fields */ }
Expand description
ContentCacheLayer will add content data cache support for OpenDAL.
Notes
This layer only maintains its own states. Users should care about the cache consistency by themselves. For example, in the following situations, users could get out-dated metadata cache:
- Users have operations on underlying operator directly.
- Other nodes have operations on underlying storage directly.
- Concurrent read/write/delete on the same path.
To make sure content cache consistent across the cluster, please make sure all nodes in the cluster use the same cache services like redis or tikv.
Examples
use std::sync::Arc;
use anyhow::Result;
use opendal::layers::ContentCacheLayer;
use opendal::layers::ContentCacheStrategy;
use opendal::services::memory;
use opendal::Operator;
use opendal::Scheme;
let _ = Operator::from_env(Scheme::Fs)
.expect("must init")
.layer(ContentCacheLayer::new(
Arc::new(memory::Builder::default().build().expect("must init")),
ContentCacheStrategy::Whole,
));
Implementations
sourceimpl ContentCacheLayer
impl ContentCacheLayer
sourcepub fn new(cache: Arc<dyn Accessor>, strategy: ContentCacheStrategy) -> Self
pub fn new(cache: Arc<dyn Accessor>, strategy: ContentCacheStrategy) -> Self
Create a new metadata cache layer.
Trait Implementations
sourceimpl Clone for ContentCacheLayer
impl Clone for ContentCacheLayer
sourcefn clone(&self) -> ContentCacheLayer
fn clone(&self) -> ContentCacheLayer
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for ContentCacheLayer
impl Debug for ContentCacheLayer
Auto Trait Implementations
impl !RefUnwindSafe for ContentCacheLayer
impl Send for ContentCacheLayer
impl Sync for ContentCacheLayer
impl Unpin for ContentCacheLayer
impl !UnwindSafe for ContentCacheLayer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more