Apache Geode Native C++ Reference 1.15.0
apache::geode::client::Cache Class Reference

Caches are obtained from the create method on the CacheFactory#create class. More...

#include <Cache.hpp>

Inherits apache::geode::client::GeodeCache.

Public Member Functions

void close () override
 Terminates this object cache and releases all the local resources. More...
 
virtual void close (bool keepalive)
 Terminates this object cache and releases all the local resources. More...
 
virtual AuthenticatedView createAuthenticatedView (const std::shared_ptr< Properties > &userSecurityProperties, const std::string &poolName)
 Creates an authenticated cache using the given user security properties. More...
 
PdxInstanceFactory createPdxInstanceFactory (const std::string &className) const override
 Returns a factory that can create a PdxInstance. More...
 
PdxInstanceFactory createPdxInstanceFactory (const std::string &className, bool expectDomainClass) const override
 Returns a factory that can create a PdxInstance. More...
 
virtual RegionFactory createRegionFactory (RegionShortcut regionShortcut)
 Returns the RegionFactory to create the region. More...
 
virtual std::shared_ptr< CacheTransactionManagergetCacheTransactionManager () const
 Get the CacheTransactionManager instance for this Cache. More...
 
LogLevel getLogLevel ()
 Returns the current log level. More...
 
const std::string & getName () const override
 Returns the name of this cache. More...
 
bool getPdxIgnoreUnreadFields () const override
 Returns whether Cache saves unread fields for Pdx types. More...
 
bool getPdxReadSerialized () const override
 Returns whether PdxInstance is preferred for PDX types instead of C++ object. More...
 
std::shared_ptr< QueryServicegetQueryService () override
 Gets the QueryService from which a new Query can be obtained. More...
 
virtual std::shared_ptr< QueryServicegetQueryService (const std::string &poolName) const
 Gets the QueryService from which a new Query can be obtained. More...
 
std::shared_ptr< RegiongetRegion (const std::string &path) const override
 Look up a region with the full path from root. More...
 
TypeRegistrygetTypeRegistry () const
 Returns the type registry that this cache was created with. More...
 
void initializeDeclarativeCache (const std::string &cacheXml) override
 Initializes the cache from an xml file. More...
 
bool isClosed () const override
 Indicates if this cache has been closed. More...
 
virtual void readyForEvents ()
 Send the "client ready" message to the server from a durable client. More...
 
std::vector< std::shared_ptr< Region > > rootRegions () const override
 Returns a set of root regions in the cache. More...
 
void setLogLevel (LogLevel newLevel)
 Changes the current log level to newLogLevel. More...
 

Detailed Description

Caches are obtained from the create method on the CacheFactory#create class.

When a cache will no longer be used, it should be closed. Once it is closed any attempt to use it will cause a CacheClosedException to be thrown.

A cache can have multiple root regions, each with a different name.

Member Function Documentation

◆ close() [1/2]

void apache::geode::client::Cache::close ( )
overridevirtual

Terminates this object cache and releases all the local resources.

After this cache is closed, any further method call on this cache or any region object will throw CacheClosedException, unless otherwise noted. If Cache instance created from Pool(pool is in multiuser mode), then it reset user related security data.

Exceptions
CacheClosedException,ifthe cache is already closed.

Implements apache::geode::client::RegionService.

◆ close() [2/2]

virtual void apache::geode::client::Cache::close ( bool  keepalive)
virtual

Terminates this object cache and releases all the local resources.

After this cache is closed, any further method call on this cache or any region object will throw CacheClosedException, unless otherwise noted. If Cache instance created from Pool(pool is in multiuser mode), then it reset user related security data.

Parameters
keepalivewhether to keep a durable client's queue alive
Exceptions
CacheClosedException,ifthe cache is already closed.

◆ createAuthenticatedView()

virtual AuthenticatedView apache::geode::client::Cache::createAuthenticatedView ( const std::shared_ptr< Properties > &  userSecurityProperties,
const std::string &  poolName 
)
virtual

Creates an authenticated cache using the given user security properties.

Multiple instances with different user properties can be created with a single client cache.

Application must use this instance to do operations, when multiuser-authentication is set to true.

See also
RegionService
PoolFactory::setMultiuserAuthentication(boolean)
Returns
the RegionService instance associated with a user and given properties.
Exceptions
UnsupportedOperationExceptionwhen invoked with multiuser-authentication as false.
Parameters
userSecurityPropertiesthe security properties of a user.
poolNamethe pool that the users should be authenticated against. Set if there are more than one Pool in Cache.

◆ createPdxInstanceFactory() [1/2]

PdxInstanceFactory apache::geode::client::Cache::createPdxInstanceFactory ( const std::string &  className) const
overridevirtual

Returns a factory that can create a PdxInstance.

Parameters
classNamethe fully qualified class name that the PdxInstance will become when it is fully deserialized.
Exceptions
IllegalStateExceptionif the className is nullptr or invalid.
Returns
the factory

Implements apache::geode::client::RegionService.

◆ createPdxInstanceFactory() [2/2]

PdxInstanceFactory apache::geode::client::Cache::createPdxInstanceFactory ( const std::string &  className,
bool  expectDomainClass 
) const
overridevirtual

Returns a factory that can create a PdxInstance.

Parameters
classNamethe fully qualified class name that the PdxInstance will become when it is fully deserialized.
expectDomainClassWhether or not created PdxType represents a Java domain class.
Exceptions
IllegalStateExceptionif the className is nullptr or invalid.
Returns
the factory

Implements apache::geode::client::RegionService.

◆ createRegionFactory()

virtual RegionFactory apache::geode::client::Cache::createRegionFactory ( RegionShortcut  regionShortcut)
virtual

Returns the RegionFactory to create the region.

Before creating the Region, one can set region attributes using this instance.

Parameters
regionShortcutTo create the region specific type,
See also
RegionShortcut

◆ getCacheTransactionManager()

virtual std::shared_ptr< CacheTransactionManager > apache::geode::client::Cache::getCacheTransactionManager ( ) const
virtual

Get the CacheTransactionManager instance for this Cache.

Returns
The CacheTransactionManager instance.
Exceptions
CacheClosedExceptionif the cache is closed.

◆ getLogLevel()

LogLevel apache::geode::client::Cache::getLogLevel ( )

Returns the current log level.

Returns
the current log level.

◆ getName()

const std::string & apache::geode::client::Cache::getName ( ) const
overridevirtual

Returns the name of this cache.

Returns
the string name of this cache

Implements apache::geode::client::GeodeCache.

◆ getPdxIgnoreUnreadFields()

bool apache::geode::client::Cache::getPdxIgnoreUnreadFields ( ) const
overridevirtual

Returns whether Cache saves unread fields for Pdx types.

Implements apache::geode::client::GeodeCache.

◆ getPdxReadSerialized()

bool apache::geode::client::Cache::getPdxReadSerialized ( ) const
overridevirtual

Returns whether PdxInstance is preferred for PDX types instead of C++ object.

Implements apache::geode::client::GeodeCache.

◆ getQueryService() [1/2]

std::shared_ptr< QueryService > apache::geode::client::Cache::getQueryService ( )
overridevirtual

Gets the QueryService from which a new Query can be obtained.

Returns
A smart pointer to the QueryService.

Implements apache::geode::client::RegionService.

◆ getQueryService() [2/2]

virtual std::shared_ptr< QueryService > apache::geode::client::Cache::getQueryService ( const std::string &  poolName) const
virtual

Gets the QueryService from which a new Query can be obtained.

Parameters
poolNamePass poolname if pool is created from cache.xml or PoolManager
Returns
A smart pointer to the QueryService.

◆ getRegion()

std::shared_ptr< Region > apache::geode::client::Cache::getRegion ( const std::string &  path) const
overridevirtual

Look up a region with the full path from root.

If Pool attached with Region is in multiusersecure mode then don't use return instance of region as no credential are attached with this instance. Get region from RegionService instance of Cache.

See also
Cache::createAuthenticatedView(std::shared_ptr<Properties>).
Parameters
paththe region's name, such as AuthRegion.
Returns
region, or nullptr if no such region exists.

Implements apache::geode::client::RegionService.

◆ getTypeRegistry()

TypeRegistry & apache::geode::client::Cache::getTypeRegistry ( ) const

Returns the type registry that this cache was created with.

◆ initializeDeclarativeCache()

void apache::geode::client::Cache::initializeDeclarativeCache ( const std::string &  cacheXml)
overridevirtual

Initializes the cache from an xml file.

Parameters
cacheXmlValid cache.xml file

Implements apache::geode::client::GeodeCache.

◆ isClosed()

bool apache::geode::client::Cache::isClosed ( ) const
overridevirtual

Indicates if this cache has been closed.

After a new cache object is created, this method returns false; After the close is called on this cache object, this method returns true.

Returns
true, if this cache is closed; false, otherwise

Implements apache::geode::client::RegionService.

◆ readyForEvents()

virtual void apache::geode::client::Cache::readyForEvents ( )
virtual

Send the "client ready" message to the server from a durable client.

◆ rootRegions()

std::vector< std::shared_ptr< Region > > apache::geode::client::Cache::rootRegions ( ) const
overridevirtual

Returns a set of root regions in the cache.

This set is a snapshot and is not backed by the Cache. The vector passed in is cleared and the regions are added to it.

Implements apache::geode::client::RegionService.

◆ setLogLevel()

void apache::geode::client::Cache::setLogLevel ( LogLevel  newLevel)

Changes the current log level to newLogLevel.


Apache Geode C++ Cache API Documentation