Show / Hide Table of Contents

# Interface ICacheLock

Cache locking interface.

All members are thread-safe and may be used concurrently from multiple threads.

##### Inherited Members

System.IDisposable.Dispose()

###### Namespace: Apache.Ignite.Core.Cache

###### Assembly: Apache.Ignite.Core.dll

##### Syntax

    public interface ICacheLock : IDisposable

### Methods

#### Enter()

Acquires an exclusive lock.

##### Declaration

    void Enter()

#### Exit()

Releases an exclusive lock on the specified object. System.IDisposable.Dispose() does not call this method and will throw System.Threading.SynchronizationLockException if this lock is acquired.

##### Declaration

    void Exit()

#### TryEnter()

Acquires an exclusive lock only if it is free at the time of invocation.

##### Declaration

    bool TryEnter()

##### Returns

Type | Description
--- | ---
System.Boolean | True if the current thread acquires the lock; otherwise, false.

#### TryEnter(TimeSpan)

Attempts, for the specified amount of time, to acquire an exclusive lock.

##### Declaration

    bool TryEnter(TimeSpan timeout)

##### Parameters

Type | Name | Description
--- | --- | ---
System.TimeSpan | timeout | A System.TimeSpan representing the amount of time to wait for the lock. A value of -1 millisecond specifies an infinite wait.

##### Returns

Type | Description
--- | ---
System.Boolean | True if the current thread acquires the lock; otherwise, false.