org.apache.geode.cache

## Interface GemFireCache

- All Superinterfaces:
    java.lang.AutoCloseable, RegionService
  All Known Subinterfaces:
    Cache, ClientCache

      public interface GemFireCache
      extends RegionService

  GemFireCache represents the singleton cache that must be created in order to use GemFire in a Java virtual machine. Users must create either a `Cache` for a peer/server JVM or a `ClientCache` for a client JVM. Instances of this interface are created using one of the following methods:
  - `CacheFactory.create()` creates a peer/server instance of `Cache`.
  - `ClientCacheFactory.create()` creates a client instance of `ClientCache`.
  Since:
    GemFire 6.5

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `DiskStoreFactory` | `createDiskStoreFactory()` create diskstore factory
    `GatewaySenderFactory` | `createGatewaySenderFactory()`
    `DiskStore` | `findDiskStore(java.lang.String name)` Returns the DiskStore by name or `null` if no disk store is found.
    `CacheTransactionManager` | `getCacheTransactionManager()` Get the CacheTransactionManager instance for this Cache.
    `boolean` | `getCopyOnRead()` Indicates whether the "copy on read" is enabled for this cache.
    `DistributedSystem` | `getDistributedSystem()` Returns the distributed system used by this cache.
    `Declarable` | `getInitializer()` Returns the Declarable used to initialize this cache or `null` if it does not have an initializer.
    `java.util.Properties` | `getInitializerProps()` Returns the Properties used to initialize the cache initializer or `null` if no initializer properties exist.
    `javax.naming.Context` | `getJNDIContext()` Returns the JNDI context associated with the Cache.
    `LogWriter` | `getLogger()` Gets the logging object for GemFire.
    `java.lang.String` | `getName()` Returns the name of this cache.
    `java.lang.String` | `getPdxDiskStore()` Returns the disk store used for PDX meta data
    `boolean` | `getPdxIgnoreUnreadFields()` Returns true if fields that are not read during PDX deserialization should be ignored during the PDX serialization.
    `boolean` | `getPdxPersistent()` Returns true if the PDX metadata for this cache is persistent
    `boolean` | `getPdxReadSerialized()` Returns whether { @link PdxInstance} is preferred for PDX types instead of Java object.
    `PdxSerializer` | `getPdxSerializer()` Returns the PdxSerializer used by this cache, or null if no PDX serializer is defined.
    `<K,V> RegionAttributes<K,V>` | `getRegionAttributes(java.lang.String id)` Returns the `RegionAttributes` with the given `id` or `null` if no `RegionAttributes` with that id exists.
    `ResourceManager` | `getResourceManager()` Returns the `ResourceManager` for managing this cache's resources.
    `LogWriter` | `getSecurityLogger()` Gets the security logging object for GemFire.
    `<K,V> java.util.Map<java.lang.String,RegionAttributes<K,V>>` | `listRegionAttributes()` Returns an unmodifiable mapping of ids to region attributes.
    `void` | `loadCacheXml(java.io.InputStream is)` Loads the cache configuration described in a declarative caching XML file into this cache.
    `void` | `registerPdxMetaData(java.lang.Object instance)` Registers PDX meta-data given an instance of a domain class that will be serialized with PDX.
    `void` | `setCopyOnRead(boolean copyOnRead)` Sets the "copy on read" feature for cache read operations.
    `<K,V> void` | `setRegionAttributes(java.lang.String id, RegionAttributes<K,V> attrs)` Sets the `id` of the given `RegionAttributes`.

    - ### Methods inherited from interface org.apache.geode.cache.RegionService

      `close, createPdxEnum, createPdxInstanceFactory, getCancelCriterion, getQueryService, getRegion, isClosed, rootRegions`

- - ### Method Detail

    - #### getName

          java.lang.String getName()

      Returns the name of this cache. This method does not throw `CacheClosedException` if the cache is closed.
      Returns:
        the String name of this cache

    - #### getDistributedSystem

          DistributedSystem getDistributedSystem()

      Returns the distributed system used by this cache. This method does not throw `CacheClosedException` if the cache is closed.

    - #### getResourceManager

          ResourceManager getResourceManager()

      Returns the `ResourceManager` for managing this cache's resources.
      Returns:
        `ResourceManager` for managing this cache's resources
      Since:
        GemFire 6.0

    - #### setCopyOnRead

          void setCopyOnRead(boolean copyOnRead)

      Sets the "copy on read" feature for cache read operations.
      Since:
        GemFire 4.0

    - #### getCopyOnRead

          boolean getCopyOnRead()

      Indicates whether the "copy on read" is enabled for this cache.
      Returns:
        true if "copy on read" is enabled, false otherwise.
      Since:
        GemFire 4.0

    - #### getRegionAttributes

          <K,V> RegionAttributes<K,V> getRegionAttributes(java.lang.String id)

      Returns the `RegionAttributes` with the given `id` or `null` if no `RegionAttributes` with that id exists.
      Since:
        GemFire 4.1
      See Also:
        `setRegionAttributes(java.lang.String, org.apache.geode.cache.RegionAttributes<K, V>)`

    - #### setRegionAttributes

          <K,V> void setRegionAttributes(java.lang.String id,
                                         RegionAttributes<K,V> attrs)

      Sets the `id` of the given `RegionAttributes`. If a region attributes named `name` already exists, the mapping will be overwritten with `attrs`. However, changing the mapping will not effect existing regions.
      Parameters:
        `id` - The id of the region attributes
        `attrs` - The attributes to associate with `id`. If `attrs` is `null`, any existing `RegionAttributes` associated with `id` will be removed.
      Since:
        GemFire 4.1
      See Also:
        `getRegionAttributes(java.lang.String)`

    - #### listRegionAttributes

          <K,V> java.util.Map<java.lang.String,RegionAttributes<K,V>> listRegionAttributes()

      Returns an unmodifiable mapping of ids to region attributes. The keys of the map are `String`s and the values of the map are `RegionAttributes`.
      Since:
        GemFire 4.1

    - #### loadCacheXml

          void loadCacheXml(java.io.InputStream is)
                     throws TimeoutException,
                            CacheWriterException,
                            GatewayException,
                            RegionExistsException

      Loads the cache configuration described in a declarative caching XML file into this cache. If the XML describes a region that already exists, any mutable region attributes, indexes, and region entries that are defined in the XML are updated/added.

      Because this method may perform a `put` on a `Region`, it declares that it throws a `TimeoutException`, `CacheWriterException`, `GatewayException`, or `RegionExistsException`.

      Throws:
        `CacheXmlException` - If the XML read from `is` does not conform to the dtd or if an `IOException` occurs while reading the XML.
        `TimeoutException`
        `CacheWriterException`
        `GatewayException`
        `RegionExistsException`
      Since:
        GemFire 4.1

    - #### getLogger

          LogWriter getLogger()

      Gets the logging object for GemFire. This method does not throw `CacheClosedException` if the cache is closed.
      Returns:
        the logging object

    - #### getSecurityLogger

          LogWriter getSecurityLogger()

      Gets the security logging object for GemFire. This method does not throw `CacheClosedException` if the cache is closed.
      Returns:
        the security logging object

    - #### findDiskStore

          DiskStore findDiskStore(java.lang.String name)

      Returns the DiskStore by name or `null` if no disk store is found.
      Parameters:
        `name` - the name of the disk store to find. If `null` then the default disk store, if it exists, is returned.
      Since:
        GemFire 6.5

    - #### createDiskStoreFactory

          DiskStoreFactory createDiskStoreFactory()

      create diskstore factory
      Since:
        GemFire 6.5

    - #### createGatewaySenderFactory

          GatewaySenderFactory createGatewaySenderFactory()

    - #### getPdxReadSerialized

          boolean getPdxReadSerialized()

      Returns whether { @link PdxInstance} is preferred for PDX types instead of Java object.
      Since:
        GemFire 6.6
      See Also:
        `CacheFactory.setPdxReadSerialized(boolean)`, `ClientCacheFactory.setPdxReadSerialized(boolean)`

    - #### getPdxSerializer

          PdxSerializer getPdxSerializer()

      Returns the PdxSerializer used by this cache, or null if no PDX serializer is defined.
      Since:
        GemFire 6.6
      See Also:
        `CacheFactory.setPdxSerializer(PdxSerializer)`, `ClientCacheFactory.setPdxSerializer(PdxSerializer)`

    - #### getPdxDiskStore

          java.lang.String getPdxDiskStore()

      Returns the disk store used for PDX meta data
      Since:
        GemFire 6.6
      See Also:
        `CacheFactory.setPdxDiskStore(String)`, `ClientCacheFactory.setPdxDiskStore(String)`

    - #### getPdxPersistent

          boolean getPdxPersistent()

      Returns true if the PDX metadata for this cache is persistent
      Since:
        GemFire 6.6
      See Also:
        `CacheFactory.setPdxPersistent(boolean)`, `ClientCacheFactory.setPdxPersistent(boolean)`

    - #### getPdxIgnoreUnreadFields

          boolean getPdxIgnoreUnreadFields()

      Returns true if fields that are not read during PDX deserialization should be ignored during the PDX serialization.
      Since:
        GemFire 6.6
      See Also:
        `CacheFactory.setPdxIgnoreUnreadFields(boolean)`, `ClientCacheFactory.setPdxIgnoreUnreadFields(boolean)`

    - #### registerPdxMetaData

          void registerPdxMetaData(java.lang.Object instance)

      Registers PDX meta-data given an instance of a domain class that will be serialized with PDX.

      Note that this method serializes the given instance so PDX must already be configured to do the serialization.

      Note that if the instance is not of a class that will be serialized with PDX then no meta-data is registered.

      Note that in most cases this method never needs to be called. Currently it is only needed by the JdbcLoader when gets are done for JDBC data that was not written to the table using geode.

      Parameters:
        `instance` - the instance of the domain class for which meta-data is to be registered
      Throws:
        `SerializationException` - if the instance can not be serialized or is not serialized with PDX
      Since:
        Geode 1.6

    - #### getCacheTransactionManager

          CacheTransactionManager getCacheTransactionManager()

      Get the CacheTransactionManager instance for this Cache.
      Returns:
        The CacheTransactionManager instance.
      Throws:
        `CacheClosedException` - if the cache is closed.
      Since:
        GemFire 4.0

    - #### getJNDIContext

          javax.naming.Context getJNDIContext()

      Returns the JNDI context associated with the Cache.
      Returns:
        javax.naming.Context Added as part of providing JTA implementation in Gemfire.
      Since:
        GemFire 4.0

    - #### getInitializer

          Declarable getInitializer()

      Returns the Declarable used to initialize this cache or `null` if it does not have an initializer.
      Since:
        GemFire 6.6

    - #### getInitializerProps

          java.util.Properties getInitializerProps()

      Returns the Properties used to initialize the cache initializer or `null` if no initializer properties exist.
      Since:
        GemFire 6.6