pub trait CacheKeyLock {
// Required methods
fn lock(&self, key: &CacheKey, stale_writer: bool) -> Locked;
fn release(&self, key: &CacheKey, permit: WritePermit, reason: LockStatus);
// Provided methods
fn trace_lock_wait(
&self,
span: &mut Span,
_read_lock: &ReadLock,
lock_status: LockStatus,
) { ... }
fn custom_lock_status(&self, _custom_no_cache: &'static str) -> LockStatus { ... }
}Required Methods§
Sourcefn lock(&self, key: &CacheKey, stale_writer: bool) -> Locked
fn lock(&self, key: &CacheKey, stale_writer: bool) -> Locked
Try to lock a cache fetch
If stale_writer is true, this fetch is to revalidate an asset already in cache.
Else this fetch was a cache miss (i.e. not found via lookup, or force missed).
Users should call after a cache miss before fetching the asset. The returned Locked will tell the caller either to fetch or wait.
Sourcefn release(&self, key: &CacheKey, permit: WritePermit, reason: LockStatus)
fn release(&self, key: &CacheKey, permit: WritePermit, reason: LockStatus)
Release a lock for the given key
When the write lock is dropped without being released, the read lock holders will consider it to be failed so that they will compete for the write lock again.
Provided Methods§
Sourcefn trace_lock_wait(
&self,
span: &mut Span,
_read_lock: &ReadLock,
lock_status: LockStatus,
)
fn trace_lock_wait( &self, span: &mut Span, _read_lock: &ReadLock, lock_status: LockStatus, )
Set tags on a trace span for the cache lock wait.
Sourcefn custom_lock_status(&self, _custom_no_cache: &'static str) -> LockStatus
fn custom_lock_status(&self, _custom_no_cache: &'static str) -> LockStatus
Set a lock status for a custom NoCacheReason.