This is a simple example that demonstrates eviction of entries from a region. This allows control over the system resources consumed by any given region.
A region is a collection of entries which are tuples of key and value. Each entry requires memory for the key object, the value object, and some overhead. Regions that contain a large number of entries, entries of a large size, or both can consume enough system resources to impact overall system performance, even for other regions.
A region can have eviction enabled to enforce an upper limit on either the total number of entries or the total amount of memory consumed by the entries. The region will then enforce the specified limits on its in-memory resource consumption. When an operation would exceed those limits, the region will take an action to assure that the limits will not be exceeded after the operation completes. The region can either destroy one or more entries or overflow one or more entries to disk.
This example assumes you have installed Java and Geode.
geode-examples/eviction directory, build the example and run unit tests.
$ ../gradlew build
Next start a locator, start a server, and create a region.
$ gfsh run --file=scripts/start.gfsh
Run the example to demonstrate eviction.
$ ../gradlew run
Shut down the system.
$ gfsh run --file=scripts/stop.gfsh