LATEST VERSION: 9.0.6 - CHANGELOG
Pivotal GemFire® Native Client v9.0

API Programming Example – C++

The next example uses the C++ API to implement a cache loader, which is generally used to retrieve data from an outside source.

CacheablePtr TestCacheLoader::load(const RegionPtr& region,
                                   const CacheableKeyPtr& key,
                                   const UserDataPtr& aCallbackArgument)
{
  m_bInvoked = true;
  printf("CacheLoader.load : %s\n", printEvent(region, key,
          aCallbackArgument).c_str());
  CacheablePtr value = NULLPTR;
  try {
    value = region->get(key, aCallbackArgument);
  } catch(Exception& ex) {
    fprintf(stderr, "Exception in TestCacheCallback::printEvent [%s]\n", ex.getMessage());
  }
  if (value != NULLPTR) {
    printf( "Loader found value: ");
    std::string formatValue = printEntryValue(value);
    printf( "%s\n",formatValue.c_str());
  } else {
    printf( " Loader did not find a value");
  }

  return value;
}