Data Grid Code Tutorials
Learn how to use Data Grid capabilities
Abstract
Red Hat Data Grid Copy linkLink copied to clipboard!
Data Grid is a high-performance, distributed in-memory data store.
- Schemaless data structure
- Flexibility to store different objects as key-value pairs.
- Grid-based data storage
- Designed to distribute and replicate data across clusters.
- Elastic scaling
- Dynamically adjust the number of nodes to meet demand without service disruption.
- Data interoperability
- Store, retrieve, and query data in the grid from different endpoints.
Data Grid documentation Copy linkLink copied to clipboard!
Documentation for Data Grid is available on the Red Hat customer portal.
Data Grid downloads Copy linkLink copied to clipboard!
Access the Data Grid Software Downloads on the Red Hat customer portal.
You must have a Red Hat account to access and download Data Grid software.
Making open source more inclusive Copy linkLink copied to clipboard!
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Chapter 1. Remote caches Copy linkLink copied to clipboard!
Deploy multiple Data Grid Server instances to create remote cache clusters that give you a fault-tolerant and scalable data tier with high-speed access from Hot Rod and REST clients.
1.1. Remote cache tutorials Copy linkLink copied to clipboard!
To run these tutorials you need at least one locally running instance of Data Grid Server.
You can download the distribution and run the following commands:
./bin/cli.sh user create admin -p "password" ./bin/server.sh
$ ./bin/cli.sh user create admin -p "password"
$ ./bin/server.sh
Data Grid Server enables authentication and authorization by default. Creating a user named admin gives you administrative access to Infinispan Server.
Building and running remote cache tutorials
You can build and run remote cache tutorials directly in your IDE or from the command line as follows:
mvn -s /path/to/maven-settings.xml clean package exec:exec
$ mvn -s /path/to/maven-settings.xml clean package exec:exec
1.2. Hot Rod Java client tutorials Copy linkLink copied to clipboard!
- Hot Rod Java clients require JDK 8 or later. However, Data Grid recommends using Java 11 at a minimum.
| Tutorial link | Description |
|---|---|
| The simplest code example that demonstrates how a remote distributed cache works. | |
| Demonstrates how to configure caches dynamically when we connect to the Data Grid Server. | |
| Demonstrates how configure near caching to improve the read performance in remote caches. | |
| Demonstrates how to use the Administration API to create caches and cache templates dynamically. | |
| Demonstrates how encoding of caches work. | |
| Detect when data changes in a remote cache with Client Listeners. | |
| Demonstrates how to query remote cache values. | |
| Demonstrates how to use Continuous Query and remote caches. | |
| Demonstrates how remote transactions work. | |
| Demonstrates how to configure caches that have authorization enabled. | |
| Demonstrates how to connect to Data Grid Server with TLS authorization. | |
| Demonstrates how remote counters work. | |
| Demonstrates how remote multimap works. | |
| Demonstrates how to register server tasks and how to execute them from the Hot Rod client. | |
| Demonstrates how to use the Data Grid and JUnit 5 extension. | |
| Demonstrates how to use the Data Grid and persistent caches. |
Data Grid documentation
You can find more resources for Hot Rod Java clients in our documentation at:
Chapter 2. Embedded caches Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
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
$ mvn -s /path/to/maven-settings.xml clean package exec:exec
| Tutorial link | Description |
|---|---|
| Demonstrates how Distributed Caches work. | |
| Demonstrates how Replicated Caches work. | |
| Demonstrates how Invalidated Caches work. | |
| Demonstrates how transactions work. | |
| Demonstrates how Distributed Streams work. | |
| Demonstrates how JCache works. | |
| Demonstrates how Functional Map API works. | |
| Demonstrates how the Map API works with Data Grid caches. | |
| Demonstrates how to use Multimap. | |
| Uses Data Grid Query to perform full-text queries on cache values. | |
| Detects when data changes in an embedded cache with Clustered Listeners. | |
| Demonstrates how to use an embedded Clustered Counter. | |
| Demonstrates how to use an embedded Clustered Lock. | |
| Demonstrates how to use an embedded Clustered Counter. |
Data Grid documentation
You can find more resources about embedded caches in our documentation at:
Chapter 3. Spring and Spring Boot Copy linkLink copied to clipboard!
3.1. Spring and Spring Boot tutorials Copy linkLink copied to clipboard!
These code tutorials use Data Grid Server and require at least one running instance.
Run Spring examples
mvn -s /path/to/maven-settings.xml package exec:exec
$ mvn -s /path/to/maven-settings.xml package exec:exec
Run Spring Boot examples
mvn -s /path/to/maven-settings.xml spring-boot:run
$ mvn -s /path/to/maven-settings.xml spring-boot:run
Displaying actuator statistics
Navigate to http://localhost:8080/actuator/metrics in your browser to display a list of available metrics. Cache metrics are prefixed with "cache." Display each metric for each cache using tags. For example for the 'puts' stats in the basque-names cache:
http://localhost:8080/actuator/metrics/cache.puts?tag=name:basque-names
Collecting statistics with Prometheus
The prometheus.yml file in this project contains a host.docker.internal binding that allows Prometheus to scrap metrics that the Spring actuator exposes.
Change the YOUR_PATH value in the following command to the directory where Prometheus is running and then run:
Podman
podman run -d --name=prometheus -p 9090:9090 -v YOUR_PATH/integrations/spring-boot/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml
$ podman run -d --name=prometheus -p 9090:9090 -v YOUR_PATH/integrations/spring-boot/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml
| Tutorial link | Description |
|---|---|
| Demonstrates how to use Spring Caches with Spring Boot and the Data Grid Server. | |
| Demonstrates how to use Spring Session with Spring Boot and the Data Grid Server. | |
| Demonstrates how to use Spring Caches with Spring Boot and Data Grid Embedded. | |
| Demonstrates how to use Spring Session with Spring Boot and Data Grid Embedded. | |
| Demonstrates how to use Spring Cache and Data Grid Embedded without Spring Boot. | |
| Demonstrates how to use Spring Session and Data Grid Embedded without Spring Boot. |
Data Grid documentation
You can find more resources in our documentation at: