using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.DistributedLocking.Exceptions;
namespace Umbraco.Cms.Core.DistributedLocking;
///
/// Represents a class responsible for managing distributed locks.
///
///
/// 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.
///
///
///
public interface IDistributedLockingMechanism
{
///
/// Gets a value indicating whether this distributed locking mechanism can be used.
///
bool Enabled { get; }
///
/// Obtains a distributed read lock.
///
///
/// When timeout is null, implementations should use
/// .
///
/// Failed to obtain distributed read lock in time.
IDistributedLock ReadLock(int lockId, TimeSpan? obtainLockTimeout = null);
///
/// Obtains a distributed read lock.
///
///
/// When timeout is null, implementations should use
/// .
///
/// Failed to obtain distributed write lock in time.
IDistributedLock WriteLock(int lockId, TimeSpan? obtainLockTimeout = null);
}