Method GetIfNewer
GetIfNewer(String, ref CacheItemVersion)
Gets an object from the cache only if a newer version of the object exists in cache.
Declaration
public virtual object GetIfNewer(string key, ref CacheItemVersion version)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | key used to reference the desired object |
CacheItemVersion | version | The version of the desired object passed by reference. |
Returns
Type | Description |
---|---|
System.Object | If a newer object exists in the cache, the object is returned. Otherwise, null is returned. |
Examples
The following example demonstrates how to get a newer version of the item from cache if it exists.
Cache cache = NCache.InitializeCache("myCache");
cache.GetIfNewer("key", ref itemVersion);
GetIfNewer(String, String, String, ref CacheItemVersion)
Gets an object from the cache only if a newer version of the object exists in cache.
Declaration
public virtual object GetIfNewer(string key, string group, string subGroup, ref CacheItemVersion version)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | key used to reference the desired object |
System.String | group | The group of the cached object |
System.String | subGroup | The subGroup of the cached object |
CacheItemVersion | version | The version of the desired object passed by reference. |
Returns
Type | Description |
---|---|
System.Object | If a newer object exists in the cache, the object is returned. Otherwise, null is returned. |
Examples
The following example demonstrates how to get a newer version of the item from cache if it exists.
Cache cache = NCache.InitializeCache("myCache");
cache.GetIfNewer("key", "Alpha", null, ref itemVersion);