Retrieves the specified item from the Cache object and also locks the object if required.

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 override Object Get(
	string key,
	TimeSpan lockTimeout,
	ref LockHandle lockHandle,
	bool acquireLock
)
Visual Basic
Public Overrides Function Get ( 
	key As String,
	lockTimeout As TimeSpan,
	ByRef lockHandle As LockHandle,
	acquireLock As Boolean
) As Object
Visual C++
public:
virtual Object^ Get(
	String^ key, 
	TimeSpan lockTimeout, 
	LockHandle^% lockHandle, 
	bool acquireLock
) override

Parameters

key
Type: System..::..String
The identifier for the cache item to retrieve.
lockTimeout
Type: System..::..TimeSpan
lockHandle
Type: Alachisoft.NCache.Web.Caching..::..LockHandle%
acquireLock
Type: System..::..Boolean
A flag to determine whether to acquire a lock or not.

Return Value

Type: Object
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 and acquire a lock
 Copy imageCopy
object lockId = null;
DateTime nowTime = DateTime.Now;

object cachedItem = theCache.Get("cachedItemKey", ref lockId, ref nowTime, true);

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionkey contains a null reference (Nothing in Visual Basic).
System..::..ArgumentExceptionkey is not serializable.

See Also