Using A Cache Loader


Introduction

This is a simple example that demonstrates loading values using a VMware GemFire CacheLoader.

This is a simple example that demonstrates loading values using a CacheLoader. Invoking Region.get() causes the CacheLoader to produce a value that is stored in the region. This approach is commonly used to fetch data from other systems like a database.

This example assumes you have installed JDK11 and GemFire.


Steps

From the gemfire-examples/loader directory, build the example and run unit tests

 $ ../gradlew build

Next start the locator and two servers

 
 $ gfsh run --file=scripts/start.gfsh
 

Run the example to load the entries

 $ ../gradlew run

The example fetches the entries twice. The first retrieval is slow, simulating a network call. Subsequent retrievals are much faster since the values are stored in the cache. The loader logs requests into the GemFire server logs. You can find those at build/server1/server1.log or build/server2/server2.log.

Shut down the system:

 $ gfsh run --file=scripts/stop.gfsh

On this page