Acquire a lock on an item in cache.
Namespace: Alachisoft.NCache.Web.CachingAssembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: 4.1.0.0 (4.1.0.0)
Syntax
C# |
---|
public virtual bool Lock( string key, TimeSpan lockTimeout, out LockHandle lockHandle ) |
Visual Basic |
---|
Public Overridable Function Lock ( _ key As String, _ lockTimeout As TimeSpan, _ <OutAttribute> ByRef lockHandle As LockHandle _ ) As Boolean |
Visual C++ |
---|
public: virtual bool Lock( String^ key, TimeSpan lockTimeout, [OutAttribute] LockHandle^% lockHandle ) |
Parameters
- key
- Type: System..::..String
key of cached item to be locked.
- lockTimeout
- Type: System..::..TimeSpan
TimeSpan after which the lock is automatically released.
- lockHandle
- Type: Alachisoft.NCache.Web.Caching..::..LockHandle%
An instance of [!:Lockhandle] that will be filled in with the lock information if lock is acquired successfully.
Return Value
Whether or not lock was acquired successfully.Examples
Following example demonstrates how to lock a cached item.
CopyC#
... LockHandle lockHandle = new LockHandle(); bool locked = theCache.lock("cachedItemKey", new TimeSpan(0,0,10), out lockHandle); ...