此内容没有您所选择的语言版本。

Chapter 2. Embedded caches


Add Data Grid as a dependency to your Java project and use embedded caches that increase application performance and give you capabilities to handle complex use cases.

2.1. Embedded cache tutorials

You can run embedded cache tutorials directly in your IDE or from the command line as follows:

$ mvn -s /path/to/maven-settings.xml clean package exec:exec
Copy to Clipboard Toggle word wrap
Expand
Tutorial linkDescription

Distributed caches

Demonstrates how Distributed Caches work.

Replicated caches

Demonstrates how Replicated Caches work.

Invalidated caches

Demonstrates how Invalidated Caches work.

Transactions

Demonstrates how transactions work.

Streams

Demonstrates how Distributed Streams work.

JCache integration

Demonstrates how JCache works.

Functional Maps

Demonstrates how Functional Map API works.

Map API

Demonstrates how the Map API works with Data Grid caches.

Multimap

Demonstrates how to use Multimap.

Queries

Uses Data Grid Query to perform full-text queries on cache values.

Clustered Listeners

Detects when data changes in an embedded cache with Clustered Listeners.

Counters

Demonstrates how to use an embedded Clustered Counter.

Clustered Locks

Demonstrates how to use an embedded Clustered Lock.

Clustered execution

Demonstrates how to use an embedded Clustered Counter.

Data Grid documentation

You can find more resources about embedded caches in our documentation at:

2.2. Kubernetes and Openshift tutorial

This tutorial contains instructions on how to run Infinispan library mode (as a microservice) in Kubernetes/OpenShift.

Prerequisites: Maven and Docker daemon running in the background.

Prerequisites

  • A running Openshift or Kubernetes cluster

Building the tutorial

This tutorial is built using the maven command:

mvn package
Copy to Clipboard Toggle word wrap

Note that target/ directory contains additional directories like docker (with generated Dockerfile) and classes/META-INF/jkube with Kubernetes and OpenShift deployment templates.

Tip

If the Docker Daemon is down, the build will omit processing Dockerfiles. Use docker profile to turn it on manually.

Deploying the tutorial to Kubernetes

This is handle by the JKube maven plugin, just invoke:

mvn k8s:build k8s:push k8s:resource k8s:apply -Doptions.image=<IMAGE_NAME> 
1
Copy to Clipboard Toggle word wrap
1
IMAGE_NAME must be replaced with the FQN of the container to deploy to Kubernetes. This container must be created in a repository that you have permissions to push to and is accessible from within your Kubernetes cluster.

Viewing and scaling up

Everything should be up and running at this point. Now login into the OpenShift or Kubernetes cluster and scale the application

kubectl scale --replicas=3  deployment/$(kubectl get rs --namespace=myproject | grep infinispan | awk '{print $1}') --namespace=myproject
Copy to Clipboard Toggle word wrap

Undeploying the tutorial

This is handled by the JKube maven plugin, just invoke:

mvn k8s:undeploy
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat