Introduction to Apache Geode Cache Management

Caches provide in-memory storage and management of your data.

 

      Organize data in the cache into data regions, each with its own configurable behavior. The cache stores data in the form of key-value pairs in regions called data items. Caches also provide features such as transactions, data queries, disk storage management, and logging. Check out the java documentationorg.apache.geode.cache.Cache。

 

       You typically configure the cache using the gfsh command-line tool or a combination of xml declarations and API calls. Geode loads and processes the xml declaration when you first create the cache. Geode has a cache that manages server and node caches, and a cache that manages clients. The cache server process automatically creates its server cache when it starts. In your application process, cache creation returns a server/node or client cache. From this point, you can manage the cache through the API.

 

Cache API

 

Geode's caching API provides specialized behavior for different system member types and security settings.

  • org.apache.geode.cache.RegionService. Typically, you use  RegionServicefunctionality through Cache and ClientCahe instantiations. RegionService实例。RegionServiceYou can only use the application programming interface in the special case of a secure client application serving multiple users to provide access to existing cached data areas and standard query services for users with access restrictions . For client-side caching, queries are sent to the server layer. For server and node caches, queries are run on the current cache and on any available nodes.RegionService由GemFireCache来实现。
  • org.apache.geode.cache.GemFireCache. You do not specifically use the GemFireCache instance, but you use the GemFireCache functionality in the Cache and ClientCache instances. GemFireCache extends RegionService and adds common features such as region attributes, disk storage, and access to the underlying distributed system for region persistence and overflow. GemFireCache is implemented by Cache and ClientCache.
  • org.apache.geode.cache.Cache. Use the cache interface to manage server and node caches, one for each of your servers or nodes. Cache extends GemFireCache and adds server/node caching features such as communicating in distributed systems, creating regions, transactions and queries, and caching server functionality.
  • org.apache.geode≈setting_cache_initializer.cache.ClientCache. Use the ClientCache interface on the client side to manage the cache. The client process has a ClientCache, which extends GemFireCache and adds client-specific caching features such as client area creation, long-lived management for long-term client subscriptions, queries at the server and client layers, and Create a RegionService for multi-user security access.

Cache XML

      yours cache.xml必须按产品XML模式定义cache-1.0.xsd来格式化。架构定义文件在产品发布包的$GEMFIRE/schemas/geode.apache.org/schema/cache/cache-1.0.xsd.

You use one to format node and server caches, and one to format client caches.

Node/Server'scache.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<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”>
...
</cache>

 clientcache.xml

 

 

<?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”>
...
</client-cache>

 See cache.xml for more information

 

Create and close cache

     Your system configuration and cache configuration are initialized when you start your member process and create each member's cache. If you use the cluster configuration service, a member process can pick up its cache configuration from the current configuration of the cluster or group. See the Cluster Configuration Service Overview.

In this chapter the use of gemfire.propertiesandcache.xml文件的例子中的步骤中,除了要求应用程序编程接口的地方。你可以通过用程序编程接口配置你的分布式系统属性和缓存,你也可以使用配置文件和程序编程接口结合来使用。

The XML example may not include the complete list of cache.xml files. All of your declared cache configurations must conform to the product installed cache xsd  $GEMFIRE/schemas/geode.apache.org/schema/cache/cache-1.0.xsd.

For all your geode applications:

  1.  Create your cache for node/server applications, or create ClientCache for client applications. It connects to the Geode system that you have configured and initialized any data regions. Use your cache instance to access your data area and do your application work.
  2. Close your cache when you're done. This frees up resources and disconnects your application from the distributed system in an orderly fashion.

Follow the instructions in the subsections under Cache Management to customize your cache creation and application shutdown requirements. You may need to combine more than one of these instructions. For example, to create a client-side cache with security on your system, you need to follow the instructions for creating and shutting down clients and the instructions for turning off caching on a secure system.

 

Export and import cache snapshots

      To help manage cache data and speed up new environment setup, you can export a snapshot of the entire cache (all regions) and import this snapshot into a new cache, for example, you can import a production cache snapshot into a test environment to Implement data import. For more details on exporting and importing snapshots, see Cache and Region Snapshots

Manage caches with gfsh and the cluster configuration service

 

     You can use the gfsh command to manage the server cache. There are gfsh commands to create regions, start servers, and create queues and other objects. When you issue these commands, the cluster configuration service saves the cache.xml and gemfire.properties files on the locator and distributes the configuration to newly added members of the cluster. View the Cluster Services Overview

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326711835&siteId=291194637