NCache 4.6 - Online Documentation

Releasing Lock Explicitly

 
In order to release lock forcefully on a previously locked cached item, lockHandle that was used to lock the key should be specified.
 
      To utilize the API, include the following namespace in your application: Alachisoft.NCache.Web.Caching.
 
            LockHandle lockHandle = new LockHandle();
 
            string key = "Product:1001";
 
            try
            {
                // lock an existing item and save the lockHandle for 10 seconds
                bool locked = cache.Lock(key, new TimeSpan(0, 0, 10), out lockHandle);
 
                if (locked)
                {
                    // unlock locked item using saved LockHandle
                    cache.Unlock(key, lockHandle);
                }
            }
            catch (OperationFailedException ex)
            {
                // handle exception
            }
 
 
See Also