Page
Creating the replicated cache
Let's create a cache called employees, this cache will be used by the sample applications to share employee records across sites.
Configure cache in site-1
- On the Data Grid operator page, select the Cache tab then Create Cache (Figure 7).
- Select the configure via: YAML view and use the content below as an example:
-
apiVersion: infinispan.org/v2alpha1 kind: Cache metadata: name: employees namespace: rhdg-xsite spec: clusterName: dg name: employees template: | replicatedCache: mode: "ASYNC" statistics: "true" encoding: key: mediaType: "text/plain; charset=UTF-8" value: mediaType: "application/json; charset=UTF-8" locking: isolation: "REPEATABLE_READ" acquireTimeout: "0" expiration: lifespan: "600000" maxIdle: "300000" backups: site-2: backup: strategy: "SYNC" takeOffline: minWait: "120000" updates: strategy: retain
- Note: The above cache is configured to:
- Objects stored in the cache have a string key.
- Objects stored in the cache have the application/json format
- Keep objects in the cache for a maximum of 10 minutes.
- If the objects are not accessed for a period of 5 minutes, they will be removed from the cache.
- Objects are replicated to the backup site, in this case to the cache configured on site-2.
- Click Create.
Configure cache in site-2
- Repeat step 1 shown for site-1.
- For step 2, use the example below to create the cache, then select Create:
apiVersion: infinispan.org/v2alpha1 kind: Cache metadata: name: employees namespace: rhdg-xsite spec: clusterName: dg name: employees template: | replicatedCache: mode: "ASYNC" statistics: "true" encoding: key: mediaType: "text/plain; charset=UTF-8" value: mediaType: "application/json; charset=UTF-8" locking: isolation: "REPEATABLE_READ" acquireTimeout: "0" expiration: lifespan: "600000" maxIdle: "300000" backups: site-1: backup: strategy: "SYNC" takeOffline: minWait: "120000" updates: strategy: retain
Our cluster is now configured with a cache capable of replicating data between different OpenShift clusters.