Get the cache item stored in cache.

Namespace: Alachisoft.NCache.Web.Caching
Assembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: 4.3.0.0 (4.3.0.0)

Syntax

C#
public virtual CacheItem GetCacheItem(
	string key,
	TimeSpan lockTimeout,
	ref LockHandle lockHandle,
	bool acquireLock
)
Visual Basic
Public Overridable Function GetCacheItem ( 
	key As String,
	lockTimeout As TimeSpan,
	ByRef lockHandle As LockHandle,
	acquireLock As Boolean
) As CacheItem
Visual C++
public:
virtual CacheItem^ GetCacheItem(
	String^ key, 
	TimeSpan lockTimeout, 
	LockHandle^% lockHandle, 
	bool acquireLock
)

Parameters

key
Type: System..::..String
Key used to reference the desired object
lockTimeout
Type: System..::..TimeSpan
The TimeSpan after which the lock is automatically released.
lockHandle
Type: Alachisoft.NCache.Web.Caching..::..LockHandle%
An instance of LockHandle to hold the lock information.
acquireLock
Type: System..::..Boolean
A flag to determine whether to acquire a lock or not.

Return Value

Type: CacheItem
The retrieved cache item, or a null reference (Nothing in Visual Basic) if the key is not found.

Remarks

///

Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception incase of failure.

Examples

The following example demonstrates how to retrieve the value cached for an ASP.NET text box server control.
 Copy imageCopy
Cache cache = NCache.InitializeCache("myCache");
LockHandle lockHandle = new LockHandle();
CacheItem item = cache.GetCacheItem("cachedItemKey",TimeSpan.FromSeconds(30) , ref lockHandle, true);

See Also