GemStone::GemFire::Cache::Generic::ICacheLoader< TKey, TValue > Interface Template Reference

Detailed Description

template<class TKey, class TValue>
interface GemStone::GemFire::Cache::Generic::ICacheLoader< TKey, TValue >

A data-loading application plug-in that can be installed on a region.

Loaders facilitate loading of data into the cache from a third-party data source. When an application does a lookup for a key in a region and it does not exist, GemFire checks to see if any loaders are available for the region in the system and invokes them to get the value for the key into the cache.

A cache loader is defined in the RegionAttributes.

When Region.Get is called for a region entry that has a null value, the ICacheLoader.Load method of the region's cache loader is invoked. The Load method creates the value for the desired key by performing an operation such as a database query.

See also:
AttributesFactory.SetCacheLoader, RegionAttributes.CacheLoader, ICacheListener, ICacheWriter

Public Member Functions

void Close (IRegion< TKey, TValue >^region)
TValue Load (IRegion< TKey, TValue >^region, TKey key, Object^ callbackArgument)

Member Function Documentation

template<class TKey, class TValue>
void GemStone::GemFire::Cache::Generic::ICacheLoader< TKey, TValue >::Close ( IRegion< TKey, TValue >^  region  ) 

Called when the region containing this callback is destroyed, when the cache is closed.

Implementations should clean up any external resources, such as database connections. Any runtime exceptions this method throws will be logged.

It is possible for this method to be called multiple times on a single callback instance, so implementations must be tolerant of this.

See also:
Cache.Close, Region.DestroyRegion

template<class TKey, class TValue>
TValue GemStone::GemFire::Cache::Generic::ICacheLoader< TKey, TValue >::Load ( IRegion< TKey, TValue >^  region,
TKey  key,
Object^   callbackArgument 

Loads a value. Application writers should implement this method to customize the loading of a value.

This method is called by the caching service when the requested value is not in the cache. Any exception thrown by this method is propagated back to and thrown by the invocation of Region.Get that triggered this load.

region a Region for which this is called.
key the key for the cacheable
the value supplied for this key, or null if no value can be supplied. If every available loader returns a null value, Region.Get will return null.
See also:

GemFire C++ Cache .NET API Documentation