Skip to main content

LockManager

Trait LockManager 

Source
pub trait LockManager: Send + Sync {
    // Required method
    fn acquire<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        ttl: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<Option<LockGuard>, DataError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A manager that grants mutually-exclusive, TTL-bounded locks by key.

Required Methods§

Source

fn acquire<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<LockGuard>, DataError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Try to acquire key for ttl. Returns Some(guard) if the lock was free (or held by an expired acquisition), or None if a live holder owns it.

§Errors

Returns a DataError only on backend failure; contention is reported as Ok(None), not an error.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§