Interface IDistributedLockingMechanism
Represents a class responsible for managing distributed locks.
Namespace: Umbraco.Cms.Core.DistributedLocking
Assembly: Umbraco.Core.dll
Syntax
public interface IDistributedLockingMechanism
Remarks
In general the rules for distributed locks are as follows.
- Cannot obtain a write lock if a read lock exists for same lock id (except during an upgrade from reader -> writer)
- Cannot obtain a write lock if a write lock exists for same lock id.
- Cannot obtain a read lock if a write lock exists for same lock id.
- Can obtain a read lock if a read lock exists for same lock id.
Properties
View SourceEnabled
Gets a value indicating whether this distributed locking mechanism can be used.
Declaration
bool Enabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
View SourceReadLock(Int32, Nullable<TimeSpan>)
Obtains a distributed read lock.
Declaration
IDistributedLock ReadLock(int lockId, TimeSpan? obtainLockTimeout = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | lockId | |
System.Nullable<TimeSpan> | obtainLockTimeout |
Returns
Type | Description |
---|---|
IDistributedLock |
Remarks
When timeout is null, implementations should use DistributedLockingReadLockDefaultTimeout.
Exceptions
Type | Condition |
---|---|
DistributedReadLockTimeoutException | Failed to obtain distributed read lock in time. |
WriteLock(Int32, Nullable<TimeSpan>)
Obtains a distributed read lock.
Declaration
IDistributedLock WriteLock(int lockId, TimeSpan? obtainLockTimeout = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | lockId | |
System.Nullable<TimeSpan> | obtainLockTimeout |
Returns
Type | Description |
---|---|
IDistributedLock |
Remarks
When timeout is null, implementations should use DistributedLockingWriteLockDefaultTimeout.
Exceptions
Type | Condition |
---|---|
DistributedWriteLockTimeoutException | Failed to obtain distributed write lock in time. |