pub trait LockableBackend: Backend {
// Required methods
fn acquire_lock<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
timeout_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, BackendError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn release_lock<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
lock_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, BackendError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Optional extension for backends that support distributed locking.
Required Methods§
Sourcefn acquire_lock<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
timeout_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn acquire_lock<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
timeout_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Acquire a distributed lock. Returns lock_id if acquired, None if contested.
Sourcefn release_lock<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
lock_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn release_lock<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
lock_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool, BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Release a distributed lock. Returns true if released.