• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Try Free
Show / Hide Table of Contents

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.

System.TimeSpan lockTimeout

An instance of System.TimeSpan after which the lock is automatically released.

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);
Back to top Copyright © 2017 Alachisoft