Method Lock
Lock(String, TimeSpan, out LockHandle)
Acquires a lock on an item in the cache.
Declaration
bool Lock(string key, TimeSpan lockTimeout, out LockHandle lockHandle)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | Key of cached item to be locked. |
System. |
lockTimeout | An instance of System. |
Lock |
lockHandle | An instance of Lock |
Returns
Type | Description |
---|---|
System. |
Whether or not lock was acquired successfully. |
Examples
The following example demonstrates how to lock a cached item.
ICache cache = CacheManager.GetCache("demoCache");
string key = "Product0";
LockHandle lockHandle = new LockHandle();
bool locked = cache.lock(key, new TimeSpan(0,0,10), out lockHandle);