For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Near Caches

Configure a near cache in GridGain 9 to store frequently accessed data locally, eliminating network latency for a specific data subset.

A near cache is a local cache that stores the most recently or most frequently accessed data locally.

The Java examples on this page use the thin client, which requires the ignite-client module. For repository and dependency configuration, see Project Setup and Required Modules.

Benefits

GridGain can access data stored in near cache locally without additional network requests to the cluster. As a result, you can get significantly improved performance with a specific regularly accessed data subset, completely eliminating network latency and cluster load associated with these requests.

Limitations

There are currently the following limitations on near caches:

  • Near caches are available on Java clients and in embedded mode;

  • Near caches only work for tables, not caches;

  • The getAll() and containsAll() methods always read data from the cluster;

  • Only the basic key-value and record view operations are currently available. The more complicated operations are not supported, including:

    • SQL with NearCache is not supported;

    • Criterion API not supported;

    • Data streaming is not supported;

    • Continuous queries are not supported;

    • Explicit transactions are not supported;

  • Near caches can contain outdated data, if updates happened on cluster after the last read operation from it. Update frequency is controlled with the expireAfterUpdate parameter.

Configuring Near Cache

In GridGain 9, you configure near caches for individual key-value or record views. As you access data, GridGain will store it locally for later access. GridGain stores the value stored for a certain duration, and uses it in read operations instead of accessing the cluster. The value eventually expires and is re-read from the cluster.

To configure the near cache, set the cache parameters in NearCacheOptions object, and then pass this object to the table view object through TableViewOptions parameter.

The example below assumes that the node is started and initialized as described in the Embedded mode documentation.

The example above uses the KeyValueView to access data. You can use any supported table view in your code instead.

Below are the available options for near cache configuration:

Option
Description
Default value

maxEntries

Maximum number of entries in the near cache. Once the maximum cache size is reached, the oldest entry is replaced. Negative values are not allowed. Zero means no limit.

0 (no limit)

expireAfterRead

The period of time since the last time data was accessed by the client after which the entry expires and is removed from the near cache, in milliseconds. Negative values are not allowed. Zero means data does not expire.

0

expireAfterUpdate

The period of time since the latest update from cluster after which the entry expires and is removed from the near cache, in milliseconds. Zero means no expiration. Negative values are not allowed.

0

updatePollInterval

The period of time with which updates are requested from the server, in milliseconds. If 0, update polling is disabled.

0 (disabled)

updateLongPollingWaitTimeMs

The period of time each polling request waits on the server for updates, in milliseconds. Only used if updatePollInterval is greater than 0. 0 means polling requests return immediately. Negative values are not supported.

10000

This page is: Copyright © 2026 MariaDB. All rights reserved.

Last updated

Was this helpful?