gemfire::CacheFactory Class Reference


Detailed Description

A factory class that must be used to obtain instances of Cache.

To create a new cache instance, use CacheFactory::create.

To get the existing unclosed cache instance, use CacheFactory::getInstance.

An instance of DistributedSystem is required to obtain a cache instance from this factory. Because DistributedSystem only allows a single instance of itself per process, you can only have a single open cache, per process.

Static Public Member Functions

static CachePtr create (const char *name, DistributedSystemPtr &system, const CacheAttributesPtr &attrs)
 Creates a new cache that uses the specified system.
static CachePtr create (const char *name, DistributedSystemPtr &system, const char *cacheXml=0, const CacheAttributesPtr &attrs=gemfire::NullSharedBase::s_instancePtr)
 Creates a new cache that uses the specified system.
static CachePtr getAnyInstance ()
 Gets an arbitrary open instance of Cache produced by an earlier call to CacheFactory::create.
static CachePtr getInstance (const DistributedSystemPtr &system)
 Gets the instance of Cache produced by an earlier call to CacheFactory::create.
static CachePtr getInstanceCloseOk (const DistributedSystemPtr &system)
 Gets the instance of Cache produced by an earlier call to CacheFactory::create, even if it has been closed.
static const char * getProductDescription ()
 Returns the product description string including product name and version.
static const char * getVersion ()
 Returns the version of the cache implementation.


Member Function Documentation

static CachePtr gemfire::CacheFactory::create ( const char *  name,
DistributedSystemPtr system,
const CacheAttributesPtr attrs 
) [static]

Creates a new cache that uses the specified system.

Parameters:
name name to associate with the new cache; cannot be NULL; if empty then "NativeCache" is used as the name
system a DistributedSystem obtained by calling DistributedSystem::connect.
attrs optional CacheAttributes for this cache
Returns:
a Cache that uses the specified system for distribution.
Exceptions:
IllegalArgumentException If system is not connected. or name is NULL
CacheExistsException If an open cache already exists.

static CachePtr gemfire::CacheFactory::create ( const char *  name,
DistributedSystemPtr system,
const char *  cacheXml = 0,
const CacheAttributesPtr attrs = gemfire::NullSharedBase::s_instancePtr 
) [static]

Creates a new cache that uses the specified system.

Parameters:
name name to associate with the new cache; cannot be NULL; if empty then "NativeCache" is used as the name
system a DistributedSystem obtained by calling DistributedSystem::connect.
cacheXml name of the xml file from which cache will be configured.
attrs optional CacheAttributes for this cache; these override the ones provided in cacheXml.
Returns:
a Cache that uses the specified system for distribution.
Exceptions:
IllegalArgumentException If system is not connected. or name is NULL
CacheExistsException If an open cache already exists.
CacheXmlException Something went wrong while parsing the XML
IllegalStateException If xml file is well-flrmed but not valid

static CachePtr gemfire::CacheFactory::getAnyInstance (  )  [static]

Gets an arbitrary open instance of Cache produced by an earlier call to CacheFactory::create.

Exceptions:
CacheClosedException if a cache has not been created or the only created one is closed

static CachePtr gemfire::CacheFactory::getInstance ( const DistributedSystemPtr system  )  [static]

Gets the instance of Cache produced by an earlier call to CacheFactory::create.

Parameters:
system the DistributedSystem the cache was created with.
Returns:
the Cache associated with the specified system.
Exceptions:
CacheClosedException if a cache has not been created or the created one is closed
EntryNotFoundException if a cache with specified system not found

static CachePtr gemfire::CacheFactory::getInstanceCloseOk ( const DistributedSystemPtr system  )  [static]

Gets the instance of Cache produced by an earlier call to CacheFactory::create, even if it has been closed.

Parameters:
system the DistributedSystem the cache was created with.
Returns:
the Cache associated with the specified system.
Exceptions:
CacheClosedException if a cache has not been created
EntryNotFoundException if a cache with specified system is not found

static const char* gemfire::CacheFactory::getProductDescription (  )  [static]

Returns the product description string including product name and version.

static const char* gemfire::CacheFactory::getVersion (  )  [static]

Returns the version of the cache implementation.

For the 1.0 release of GemFire, the string returned is 1.0.

Returns:
the version of the cache implementation as a String


GemFire C++ Cache API Documentation