Interface IDistributedLockManager
Implements a lock mechanism that relies on a shared persisted storage (such as a database) to synchronize different processes.
Namespace: Silverback.Background
Assembly: Silverback.Core.dll
Syntax
public interface IDistributedLockManager
Methods
| Improve this doc View sourceAcquireAsync(DistributedLockSettings, CancellationToken)
Acquires a new lock on the specified resource.
Declaration
Task<DistributedLock?> AcquireAsync(DistributedLockSettings settings, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Distributed |
settings | Specifies all settings of the lock to be acquired. |
Cancellation |
cancellationToken | A Cancellation |
Returns
Type | Description |
---|---|
Task<Distributed |
A Task<TResult> representing the asynchronous operation. The task result contains the
acquired Distributed |
CheckIsStillLockedAsync(DistributedLockSettings)
Returns a boolean value indicating whether the specified lock is taken already.
Declaration
Task<bool> CheckIsStillLockedAsync(DistributedLockSettings settings)
Parameters
Type | Name | Description |
---|---|---|
Distributed |
settings | Specifies the lock to be checked. |
Returns
Type | Description |
---|---|
Task<bool> | A Task<TResult> representing the asynchronous operation. The task result contains a boolean value indicating whether the lock is taken. |
ReleaseAsync(DistributedLockSettings)
Releases the lock.
Declaration
Task ReleaseAsync(DistributedLockSettings settings)
Parameters
Type | Name | Description |
---|---|---|
Distributed |
settings | Specifies the lock to be released. |
Returns
| Improve this doc View sourceSendHeartbeatAsync(DistributedLockSettings)
Called periodically after the lock has been acquired to send an heartbeat that keeps the lock.
Declaration
Task<bool> SendHeartbeatAsync(DistributedLockSettings settings)
Parameters
Type | Name | Description |
---|---|---|
Distributed |
settings | Specifies the lock to be refreshed. |
Returns
Type | Description |
---|---|
Task<bool> | A Task<TResult> representing the asynchronous operation. The task result contains a boolean value indicating whether the lock could be refreshed. |