You have multiple client cache configuration options. Enables client-side caching using a combination of XML declarations and API calls. Close the client-side cache when finished using it.
Geode clients are processes that send most or all data requests to the Geode server system. Clients run as independent processes, they do not have their own nodes.
Note: Geode automatically ClientCache
configures your distributed system as a standalone system, which means clients have no nodes. Don't try to set for one clientgemfire.properties
mcast-port
或locators否则系统会抛出一个异常。
Create your client cache:
In yours cache.xml文件中
, use client-cache
DOCTYPE and <client-cache>
configure cache in the element. Configure your server connection pool and your zone, if needed. E.g:
<?xml version="1.0" encoding="UTF-8"?> <client-cache xmlns="http://geode.incubator.apache.org/schema/cache" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://geode.incubator.apache.org/schema/cache http://geode.incubator.apache.org/schema/cache/cache-1.0.xsd" version="1.0"> <pool name="serverPool"> <locator host="host1" port="44444"/> </pool> <region name="exampleRegion" refid="PROXY"/> </client-cache>
Note: Applications using client-cache may want to set concurrency-checks-enabled to false to see all events in the area. Geode server members can continue to use concurrency checks, but he will send all events to the client. This configuration ensures that all zone events are visible to the client, but it does not prevent the client zone from getting out of sync with the server cache. See "Regional Update Consistency"
If you use multiple server pools, configure the pool name explicitly for each client. E.g:
<pool name="svrPool1"> <locator host="host1" port="40404"/> </pool> <pool name="svrPool2"> <locator host="host2" port="40404"/> </pool> <region name="clientR1" refid="PROXY" pool-name="svrPool1"/> <region name="clientR2" refid="PROXY" pool-name="svrPool2"/> <region name="clientsPrivateR" refid="LOCAL"/>
In your java client application, ClientCacheFactory的create方法
create the cache with, for example:
ClientCache clientCache = new ClientCacheFactory().create();
This will create a server connection and press your gemfire.properties
andcache.xml声明来初始化客户端缓存。
When you're done, close your cache with the close method of your Cache instance:
cache.close();
If the client is persistent and want to maintain a persistent queue when the client cache is closed, use:
clientCache.close(true);