VMware VMware GemFire Native .NET Reference 10.4.3
Loading...
Searching...
No Matches
Apache::Geode::Client::ICacheLoader< TKey, TValue > Interface Template Reference

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

#include <ICacheLoader.hpp>

Public Member Functions

void Close (IRegion< TKey, TValue >^ region)
 Called when the region containing this callback is destroyed, when the cache is closed.
 
TValue Load (IRegion< TKey, TValue >^ region, TKey key, Object^ callbackArgument)
 Loads a value.
 

Detailed Description

template<class TKey, class TValue>
interface Apache::Geode::Client::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, Geode 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
RegionAttributesFactory.SetCacheLoader, RegionAttributes.CacheLoader, ICacheListener, ICacheWriter

Member Function Documentation

◆ Close()

template<class TKey , class TValue >
void Apache::Geode::Client::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

◆ Load()

template<class TKey , class TValue >
TValue Apache::Geode::Client::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.

Parameters
regiona Region for which this is called.
keythe key for the cacheable
callbackArgument
Returns
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
Region.Get

Apache Geode C++ Cache .NET API Documentation