Search Results for

    Show / Hide Table of Contents
    View Source

    Class LockingMechanism

    Mechanism for handling read and write locks

    Inheritance
    System.Object
    Namespace: Umbraco.Cms.Core.Scoping
    Assembly: Umbraco.Core.dll
    Syntax
    public class LockingMechanism : ILockingMechanism

    Constructors

    View Source

    LockingMechanism(IDistributedLockingMechanismFactory, ILogger<LockingMechanism>)

    Constructs an instance of LockingMechanism

    Declaration
    public LockingMechanism(IDistributedLockingMechanismFactory distributedLockingMechanismFactory, ILogger<LockingMechanism> logger)
    Parameters
    Type Name Description
    IDistributedLockingMechanismFactory distributedLockingMechanismFactory
    ILogger<LockingMechanism> logger

    Methods

    View Source

    ClearLocks(Guid)

    Clears all lock counters for a given scope instance, signalling that the scope has been disposed.

    Declaration
    public void ClearLocks(Guid instanceId)
    Parameters
    Type Name Description
    Guid instanceId

    Instance ID of the scope to clear.

    View Source

    Dispose()

    Declaration
    public void Dispose()
    View Source

    EagerReadLock(Guid, Int32[])

    Declaration
    public void EagerReadLock(Guid instanceId, params int[] lockIds)
    Parameters
    Type Name Description
    Guid instanceId
    System.Int32[] lockIds
    View Source

    EagerReadLock(Guid, Nullable<TimeSpan>, Int32[])

    Eagerly acquires a read-lock

    Declaration
    public void EagerReadLock(Guid instanceId, TimeSpan? timeout = null, params int[] lockIds)
    Parameters
    Type Name Description
    Guid instanceId
    System.Nullable<TimeSpan> timeout

    Timeout for the lock

    System.Int32[] lockIds
    View Source

    EagerWriteLock(Guid, Int32[])

    Declaration
    public void EagerWriteLock(Guid instanceId, params int[] lockIds)
    Parameters
    Type Name Description
    Guid instanceId
    System.Int32[] lockIds
    View Source

    EagerWriteLock(Guid, Nullable<TimeSpan>, Int32[])

    Eagerly acquires a write-lock

    Declaration
    public void EagerWriteLock(Guid instanceId, TimeSpan? timeout = null, params int[] lockIds)
    Parameters
    Type Name Description
    Guid instanceId
    System.Nullable<TimeSpan> timeout

    Timeout for the lock

    System.Int32[] lockIds
    View Source

    EnsureLocks(Guid)

    When we require a ReadLock or a WriteLock we don't immediately request these locks from the database, instead we only request them when necessary (lazily). To do this, we queue requests for read/write locks. This is so that if there's a request for either of these locks, but the service/repository returns an item from the cache, we don't end up making a DB call to make the read/write lock. This executes the queue of requested locks in order in an efficient way lazily whenever the database instance is resolved.

    Declaration
    public void EnsureLocks(Guid scopeInstanceId)
    Parameters
    Type Name Description
    Guid scopeInstanceId
    View Source

    EnsureLocksCleared(Guid)

    Declaration
    public void EnsureLocksCleared(Guid instanceId)
    Parameters
    Type Name Description
    Guid instanceId
    View Source

    GetReadLocks()

    Declaration
    public Dictionary<Guid, Dictionary<int, int>>? GetReadLocks()
    Returns
    Type Description
    System.Nullable<Umbraco.Cms.Core.Dictionary<Guid, Umbraco.Cms.Core.Dictionary<System.Int32, System.Int32>>>
    View Source

    GetWriteLocks()

    Declaration
    public Dictionary<Guid, Dictionary<int, int>>? GetWriteLocks()
    Returns
    Type Description
    System.Nullable<Umbraco.Cms.Core.Dictionary<Guid, Umbraco.Cms.Core.Dictionary<System.Int32, System.Int32>>>
    View Source

    ReadLock(Guid, Int32[])

    Declaration
    public void ReadLock(Guid instanceId, params int[] lockIds)
    Parameters
    Type Name Description
    Guid instanceId
    System.Int32[] lockIds
    View Source

    ReadLock(Guid, Nullable<TimeSpan>, Int32[])

    Read-locks some lock objects lazily.

    Declaration
    public void ReadLock(Guid instanceId, TimeSpan? timeout = null, params int[] lockIds)
    Parameters
    Type Name Description
    Guid instanceId

    Instance id of the scope who is requesting the lock

    System.Nullable<TimeSpan> timeout

    Timeout for the lock

    System.Int32[] lockIds

    Array of lock object identifiers.

    View Source

    WriteLock(Guid, Int32[])

    Declaration
    public void WriteLock(Guid instanceId, params int[] lockIds)
    Parameters
    Type Name Description
    Guid instanceId
    System.Int32[] lockIds
    View Source

    WriteLock(Guid, Nullable<TimeSpan>, Int32[])

    Write-locks some lock objects lazily.

    Declaration
    public void WriteLock(Guid instanceId, TimeSpan? timeout = null, params int[] lockIds)
    Parameters
    Type Name Description
    Guid instanceId

    Instance id of the scope who is requesting the lock

    System.Nullable<TimeSpan> timeout

    Timeout for the lock

    System.Int32[] lockIds

    Array of object identifiers.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX