| IHazelcastInstanceGetLock Method |
Returns the distributed lock instance for the specified key object.
Namespace:
Hazelcast.Core
Assembly:
Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.11
Syntax ILock GetLock(
string key
)
Function GetLock (
key As String
) As ILock
ILock^ GetLock(
String^ key
)
abstract GetLock :
key : string -> ILock
Parameters
- key
- Type: SystemString
key of the lock instance
Return Value
Type:
ILockdistributed lock instance for the specified key.
Remarks
Returns the distributed lock instance for the specified key object.
The specified object is considered to be the key for this lock.
So keys are considered equals cluster-wide as long as
they are serialized to the same byte array such as String, long,
Integer.
Locks are fail-safe. If a member holds a lock and some of the
members go down, cluster will keep your locks safe and available.
Moreover, when a member leaves the cluster, all the locks acquired
by this dead member will be removed so that these locks can be
available for live members immediately.
Examples Lock lock = hazelcastInstance.GetLock("PROCESS_LOCK");
lock.lock();
try
{
}
finally
{
lock.unlock();
}
See Also