Pivotal GemFire Native Client Cache Reference  9.0.6
gemfire::CacheLoader Class Referenceabstract

An application plug-in that can be installed on a region. More...

Inherits gemfire::SharedBase.

Public Member Functions

virtual void close (const RegionPtr &rp)
 Called when the region containing this callback is destroyed, when the cache is closed. More...
 
virtual CacheablePtr load (const RegionPtr &rp, const CacheableKeyPtr &key, const UserDataPtr &aCallbackArgument)=0
 Loads a value. More...
 
void preserveSB () const
 Atomically increment reference count. More...
 
int32_t refCount ()
 
void releaseSB () const
 Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero. More...
 

Detailed Description

An application plug-in that can be installed on a region.

Loaders facilitate loading of data into the cache. When an application does a lookup for a key in a region and it does not exist, the system 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. Allows data to be loaded from a 3rd party data source and placed into the region When Region::get is called for a region entry that has a NULLPTR value, the CacheLoader::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::getCacheLoader

Member Function Documentation

virtual void gemfire::CacheLoader::close ( const RegionPtr rp)
virtual

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.

Parameters
rpthe region pointer
See also
Cache::close
Region::destroyRegion
virtual CacheablePtr gemfire::CacheLoader::load ( const RegionPtr rp,
const CacheableKeyPtr key,
const UserDataPtr aCallbackArgument 
)
pure virtual

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
rpa Region Pointer for which this is called.
keythe key for the cacheable
helperany related user data, or NULLPTR
Returns
the value supplied for this key, or NULLPTR if no value can be supplied.
See also
Region::get .
void gemfire::SharedBase::preserveSB ( ) const
inherited

Atomically increment reference count.

int32_t gemfire::SharedBase::refCount ( )
inlineinherited
Returns
the reference count
void gemfire::SharedBase::releaseSB ( ) const
inherited

Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.


GemFire C++ Cache API Documentation