이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 16. Creating caches with Data Grid Operator
Use Cache CRs to add cache configuration with Data Grid Operator and control how Data Grid stores your data.
16.1. Data Grid caches 링크 복사링크가 클립보드에 복사되었습니다!
Cache configuration defines the characteristics and features of the data store and must be valid with the Data Grid schema. Data Grid recommends creating standalone files in XML or JSON format that define your cache configuration. You should separate Data Grid configuration from application code for easier validation and to avoid the situation where you need to maintain XML snippets in Java or some other client language.
To create caches with Data Grid clusters running on OpenShift, you should:
-
Use
CacheCR as the mechanism for creating caches through the OpenShift front end. -
Use
BatchCR to create multiple caches at a time from standalone configuration files. - Access Data Grid Console and create caches in XML or JSON format.
You can use Hot Rod or HTTP clients but Data Grid recommends Cache CR or Batch CR unless your specific use case requires programmatic remote cache creation.
Cache CRs
-
CacheCRs apply to Data Grid service pods only. -
Each
CacheCR corresponds to a single cache on the Data Grid cluster.
16.2. Creating caches with the Cache CR 링크 복사링크가 클립보드에 복사되었습니다!
Complete the following steps to create caches on Data Grid service clusters using valid configuration in XML or YAML format.
Procedure
-
Create a
CacheCR with a unique value in themetadata.namefield. -
Specify the target Data Grid cluster with the
spec.clusterNamefield. Name your cache with the
spec.namefield.NoteThe
nameattribute in the cache configuration does not take effect. If you do not specify a name with thespec.namefield then the cache uses the value of themetadata.namefield.-
Add a cache configuration with the
spec.templatefield. Apply the
CacheCR, for example:oc apply -f mycache.yaml cache.infinispan.org/mycachedefinition created
oc apply -f mycache.yaml cache.infinispan.org/mycachedefinition createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Cache CR examples
XML
YAML
16.3. Adding persistent cache stores 링크 복사링크가 클립보드에 복사되었습니다!
You can add persistent cache stores to Data Grid service pods to save data to the persistent volume.
Data Grid creates a Single File cache store, .dat file, in the /opt/infinispan/server/data directory.
Procedure
Add the
<file-store/>element to thepersistenceconfiguration in your Data Grid cache, as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.4. Adding caches to Cache service pods 링크 복사링크가 클립보드에 복사되었습니다!
Cache service pods include a default cache configuration with recommended settings. This default cache lets you start using Data Grid without the need to create caches.
Because the default cache provides recommended settings, you should create caches only as copies of the default. If you want multiple custom caches you should create Data Grid service pods instead of Cache service pods.
Procedure
- Access the Data Grid Console and provide a copy of the default configuration in XML or JSON format.
Use the Data Grid CLI to create a copy from the default cache as follows:
[//containers/default]> create cache --template=default mycache
[//containers/default]> create cache --template=default mycacheCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.4.1. Default cache configuration 링크 복사링크가 클립보드에 복사되었습니다!
This topic describes default cache configuration for Cache service pods.
Default caches:
- Use synchronous distribution to store data across the cluster.
- Create two replicas of each entry on the cluster.
- Store cache entries as bytes in native memory (off-heap).
- Define the maximum size for the data container in bytes. Data Grid Operator calculates the maximum size when it creates pods.
- Evict cache entries to control the size of the data container. You can enable automatic scaling so that Data Grid Operator adds pods when memory usage increases instead of removing entries.
- Use a conflict resolution strategy that allows read and write operations for cache entries, even if segment owners are in different partitions.
- Specify a merge policy that removes entries from the cache when Data Grid detects conflicts.