Method Lock
Lock(String, TimeSpan, out LockHandle)
Acquire a lock on an item in cache.
Declaration
public virtual bool Lock(string key, TimeSpan lockTimeout, out LockHandle lockHandle)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | key of cached item to be locked. |
System.TimeSpan | lockTimeout | TimeSpan after which the lock is automatically released. |
LockHandle | lockHandle | An instance of |
Returns
Type | Description |
---|---|
System.Boolean | Whether or not lock was acquired successfully. |
Examples
Following example demonstrates how to lock a cached item.
...
LockHandle lockHandle = new LockHandle();
bool locked = theCache.lock("cachedItemKey", new TimeSpan(0,0,10), out lockHandle);
...