Returns the distributed lock instance for the specified key object.
Namespace: Hazelcast.CoreAssembly: Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.8.2
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.
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.
Lock lock = hazelcastInstance.GetLock("PROCESS_LOCK");
lock.lock();
try
{
}
finally
{
lock.unlock();
}
Reference