Method Get
Get(String, DSReadOption)
Retrieves the specified item from the Cache object.
Declaration
public override object Get(string key, DSReadOption dsReadOption)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The identifier for the cache item to retrieve. |
DSReadOption | dsReadOption | Options regarding reading from data source |
Returns
Type | Description |
---|---|
System.Object | The retrieved cache item, or a null reference (Nothing in Visual Basic) if the key is not found. |
Overrides
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.
NCache.Cache.Get("MyTextBox.Value");
Or simply in a class deriving from
Cache.Get("MyTextBox.Value");
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException |
|
Get(String, TimeSpan, ref LockHandle, Boolean)
Retrieves the specified item from the Cache object and also locks the object if required.
Declaration
public override object Get(string key, TimeSpan lockTimeout, ref LockHandle lockHandle, bool acquireLock)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The identifier for the cache item to retrieve. |
System.TimeSpan | lockTimeout | |
LockHandle | lockHandle | |
System.Boolean | acquireLock | A flag to determine whether to acquire a lock or not. |
Returns
Type | Description |
---|---|
System.Object | The retrieved cache item, or a null reference (Nothing in Visual Basic) if the key is not found. |
Overrides
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
object lockId = null;
DateTime nowTime = DateTime.Now;
object cachedItem = theCache.Get("cachedItemKey", ref lockId, ref nowTime, true);
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException |
|
Get(String, DSReadOption, ref CacheItemVersion)
Retrieves the specified item from the Cache object. If the object is read thru the data source, put is against the given group and sub group.
Declaration
public override object Get(string key, DSReadOption dsReadOption, ref CacheItemVersion version)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The identifier for the cache item to retrieve. |
DSReadOption | dsReadOption | Options regarding reading from data source |
CacheItemVersion | version | The version of the desired object passed by reference. |
Returns
Type | Description |
---|---|
System.Object | The retrieved cache item, or a null reference (Nothing in Visual Basic) if the key is not found. |
Overrides
Remarks
Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception incase of failure.
Note: The group and subGroup parameters are used only if the object is read thru the data source. Otherwise the object will be returned from the cache whether it belongs to the given group and sub group or not.
Examples
The following example demonstrates how to retrieve the value cached for an ASP.NET text box server control.
NCache.Cache.Get("MyTextBox.Value", "Customer", null);
Or simply in a class deriving from
Cache.Get("MyTextBox.Value", "Customer", null);
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException |
|
System.ArgumentNullException |
|
Get(String, String, String, DSReadOption)
Retrieves the specified item from the Cache object. If the object is read thru the data source, put is against the given group and sub group.
Declaration
public override object Get(string key, string group, string subGroup, DSReadOption dsReadOpt)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The identifier for the cache item to retrieve. |
System.String | group | The group of the cached object |
System.String | subGroup | The subGroup of the cached object |
DSReadOption | dsReadOpt |
Returns
Type | Description |
---|---|
System.Object | The retrieved cache item, or a null reference (Nothing in Visual Basic) if the key is not found. |
Overrides
Remarks
Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception incase of failure.
Note: The group and subGroup parameters are used only if the object is read thru the data source. Otherwise the object will be returned from the cache whether it belongs to the given group and sub group or not.
Examples
The following example demonstrates how to retrieve the value cached for an ASP.NET text box server control.
NCache.Cache.Get("MyTextBox.Value", "Customer", null);
Or simply in a class deriving from
Cache.Get("MyTextBox.Value", "group", "subGroup", "Customer", null);
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException |
|
System.ArgumentNullException |
|