pub struct Lock { /* private fields */ }Expand description
A named lock over a LockStore. Use CacheManager::lock() to obtain
one, then get() to acquire it and release() when done.
Implementations§
Source§impl Lock
impl Lock
pub fn new(store: Arc<dyn LockStore>, key: &str, ttl: Duration) -> Self
Sourcepub async fn get(&self) -> Result<bool, CacheError>
pub async fn get(&self) -> Result<bool, CacheError>
Try to acquire the lock once.
Sourcepub async fn release(&self) -> Result<bool, CacheError>
pub async fn release(&self) -> Result<bool, CacheError>
Release the lock if this instance still owns it.
Sourcepub async fn force_release(&self) -> Result<bool, CacheError>
pub async fn force_release(&self) -> Result<bool, CacheError>
Release the lock even if a different owner holds it.
Sourcepub async fn refresh(&self) -> Result<bool, CacheError>
pub async fn refresh(&self) -> Result<bool, CacheError>
Extend the lock’s TTL (Laravel’s Lock::refresh()).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Lock
impl !UnwindSafe for Lock
impl Freeze for Lock
impl Send for Lock
impl Sync for Lock
impl Unpin for Lock
impl UnsafeUnpin for Lock
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Event for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more