pub struct CacheLock { /* private fields */ }
Expand description
The global cache locking manager
Implementations§
Source§impl CacheLock
impl CacheLock
Sourcepub fn new(timeout: Duration) -> Self
pub fn new(timeout: Duration) -> Self
Create a new CacheLock with the given lock timeout
When the timeout is reached, the read locks are automatically unlocked
Sourcepub fn lock<K: CacheHashKey>(&self, key: &K) -> Locked
pub fn lock<K: CacheHashKey>(&self, key: &K) -> Locked
Try to lock a cache fetch
Users should call after a cache miss before fetching the asset. The returned Locked will tell the caller either to fetch or wait.
Sourcepub fn release<K: CacheHashKey>(&self, key: &K, reason: LockStatus)
pub fn release<K: CacheHashKey>(&self, key: &K, 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.
Auto Trait Implementations§
impl !Freeze for CacheLock
impl !RefUnwindSafe for CacheLock
impl Send for CacheLock
impl Sync for CacheLock
impl Unpin for CacheLock
impl UnwindSafe for CacheLock
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