Retrieves the specified item from the Cache object. It accepts the CacheItemVersion by reference. If null is passed for CacheItemVersion, then the version of the object from the cache is returned. If non-null CacheItemVersion is passed, then object is returned from the cache only if that is the current version of the object in the cache.

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


public virtual Object Get(
	string key,
	ref CacheItemVersion version
Visual Basic
Public Overridable Function Get ( 
	key As String,
	ByRef version As CacheItemVersion
) As Object
Visual C++
virtual Object^ Get(
	String^ key, 
	CacheItemVersion^% version


Type: System..::..String
The identifier for the cache item to retrieve.
Type: Alachisoft.NCache.Web.Caching..::..CacheItemVersion%
The version of the object.

Return Value

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


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


The following example demonstrates how to retrieve the value cached for an ASP.NET text box server control. The version of the cached object is also received.
 Copy imageCopy
Cache cache = NCache.InitializeCache("myCache");
CacheItemVersion version = null;
string textBoxValue = (string) cache.Get("MyTextBox.Value", ref version);


System..::..ArgumentNullExceptionkey contains a null reference (Nothing in Visual Basic).

See Also