pub struct BlobCache<B> { /* private fields */ }
Expand description
A disk-backed cache for objects in Blob storage.
The data for the objects in the cache is stored on disk, mmap’d, and a validated handle is stored in-memory to avoid repeatedly decoding it.
TODO: Add a limit to bound how much disk this cache can use. The Arc
return type for get_batch
seems correct, but means that a bad user could
starve the cache by indefinitely holding handles. The Arcs could be made
into weak references so the cache could forcefully reclaim the backing data,
but this is going to make performance of using the cached batches
unpredictable. I think we probably want a soft limit and a hard limit where
the soft limit does some alerting and the hard limit starts blocking (or
erroring) until disk space frees up.
Implementations
sourceimpl<B: Blob + Send + Sync + 'static> BlobCache<B>
impl<B: Blob + Send + Sync + 'static> BlobCache<B>
sourcepub fn new(
metrics: Arc<Metrics>,
blob: B,
cache_size_limit: Option<usize>
) -> Self
pub fn new(
metrics: Arc<Metrics>,
blob: B,
cache_size_limit: Option<usize>
) -> Self
Returns a new, empty cache for the given Blob storage.
sourcepub async fn get_trace_batch_async(
&self,
key: &str,
hint: CacheHint
) -> Result<Arc<BlobTraceBatchPart>, Error>
pub async fn get_trace_batch_async(
&self,
key: &str,
hint: CacheHint
) -> Result<Arc<BlobTraceBatchPart>, Error>
Asynchronously returns the batch for the given key, fetching in another thread if it’s not already in the cache.
sourceimpl<B: Blob + Send + Sync + 'static> BlobCache<B>
impl<B: Blob + Send + Sync + 'static> BlobCache<B>
sourcepub async fn set_trace_batch(
&self,
key: String,
batch: BlobTraceBatchPart,
format: ProtoBatchFormat
) -> Result<u64, Error>
pub async fn set_trace_batch(
&self,
key: String,
batch: BlobTraceBatchPart,
format: ProtoBatchFormat
) -> Result<u64, Error>
Writes a batch to backing Blob storage.
Returns the size of the encoded blob value in bytes.
sourcepub async fn delete_trace_batch(
&mut self,
batch: &TraceBatchMeta
) -> Result<(), Error>
pub async fn delete_trace_batch(
&mut self,
batch: &TraceBatchMeta
) -> Result<(), Error>
Removes a batch from both Blob storage and the local cache.
Trait Implementations
Auto Trait Implementations
impl<B> RefUnwindSafe for BlobCache<B> where
B: RefUnwindSafe,
impl<B> Send for BlobCache<B> where
B: Send + Sync,
impl<B> Sync for BlobCache<B> where
B: Send + Sync,
impl<B> Unpin for BlobCache<B>
impl<B> UnwindSafe for BlobCache<B> where
B: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> FutureExt for T
impl<T> FutureExt for T
sourcefn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
sourcefn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
sourceimpl<T> ProgressEventTimestamp for T where
T: Data + Debug + Any,
impl<T> ProgressEventTimestamp for T where
T: Data + Debug + Any,
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more