|Configuring the Native Client Cache / Cache Management|
It is important to understand the sequence of events that occur when the native client connects with a GemFire cache server.
Client threads obtain, use, and release a connection to a connection pool that maintains new connections. The number of connections that a client can establish is governed by the pool's min-connections and max-connections settings, either using client XML configuration or programmatically through the CacheFactory::setMinConnections() and CacheFactory::setMaxConnections() APIs. The defaults for min-connections is 1 and max-connections is -1 meaning the connection count can grow to accommodate the number of active threads performing region operations.
This example shows how to use cache.xml to configure a native client region with endpoints set to two cache servers:
<pool name="examplePool" subscription-enabled="true" > <server host="java_servername1" port="java_port1" /> <server host="java_servername2" port="java_port2" /> </pool> <region name="NativeClientRegion" refid="CACHING_PROXY"> <region-attributes pool-name="examplePool"/> </region>
TCP connections on the native client are specified at the cache level, or by overriding endpoints for specific regions. The connections are created as the regions are created. In addition, connections can also get created for querying without having any created regions. In this case, when endpoints are defined at the cache level no regions are yet created and a query is fired.
You can configure client-server connections in two ways. Use either the region/cache endpoints or the Pool API. For more information about the pool API, see Using Connection Pools.