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.String | key | key of cached item to be locked. |
TimeSpan | lockTimeout | An instance of |
LockHandle | lockHandle | An instance of LockHandle that will be filled in with the lock information if lock is acquired successfully. |
Returns
Type | Description |
---|---|
System.Boolean | Whether or not lock was acquired successfully. |
Examples
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);