NCache 4.6 - Online Documentation

Locking with Expiration

 
If time is specified as a value of TimeSpan, NCache would lock the item for that specified duration.
 
      To utilize the API, include the following namespace in your application: Alachisoft.NCache.Web.Caching.
 
            LockHandle lockHandle = new LockHandle();
 
            //Specify time span of 10 sec for which the item remains locked
            TimeSpan lockSpan = new TimeSpan(0, 0, 10);
 
            string key = "Product:1001";
 
            try
            {
                bool lockAcquired = cache.Lock(key, lockSpan, out lockHandle);
                //Verify that the lock is released automatically after this time period.
            }
            catch (OperationFailedException ex)
            {
                // handle exception
            }
 
 
See Also