Apache Ignite Documentation

GridGain Developer Hub - Apache Ignitetm

Welcome to the Apache Ignite developer hub run by GridGain. Here you'll find comprehensive guides and documentation to help you start working with Apache Ignite as quickly as possible, as well as support if you get stuck.

 

GridGain also provides Community Edition which is a distribution of Apache Ignite made available by GridGain. It is the fastest and easiest way to get started with Apache Ignite. The Community Edition is generally more stable than the Apache Ignite release available from the Apache Ignite website and may contain extra bug fixes and features that have not made it yet into the release on the Apache website.

 

Let's jump right in!

 

Documentation     Ask a Question     Download

 

Javadoc     Scaladoc     Examples

Near Caches

Create local client-side caches.

A partitioned cache can also be fronted by a Near cache which is a smaller local cache that stores the most recently or most frequently accessed data. Just like with a partitioned cache, you can control the size of the near cache and its eviction policies.

Near caches can be created directly on client nodes by passing NearConfiguration into the Ignite.createNearCache(NearConfiguration) or Ignite.getOrCreateNearCache(NearConfiguration) nodes. Use Ignite.getOrCreateCache(CacheConfiguration, NearCacheConfiguration) method if you need both start a distributed cache dynamically and create a near-cache for it.

// Create near-cache configuration for "myCache".
NearCacheConfiguration<Integer, Integer> nearCfg = 
    new NearCacheConfiguration<>();

// Use LRU eviction policy to automatically evict entries
// from near-cache, whenever it reaches 100_000 in size.
nearCfg.setNearEvictionPolicy(new LruEvictionPolicy<>(100_000));

// Create a distributed cache on server nodes and 
// a near cache on the local node, named "myCache".
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(
    new CacheConfiguration<Integer, Integer>("myCache"), nearCfg);
<bean class="org.apache.ignite.configuration.CacheConfiguration">
    <property name="name" value="myCache" />

    <property name="nearConfiguration">
        <bean class="org.apache.ignite.configuration.NearCacheConfiguration">
            <property name="nearEvictionPolicy">
                <bean class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">
                    <property name="maxSize" value="100000"/>
                </bean>
            </property>
        </bean>
    </property>
</bean>

In a majority of use cases, whenever utilizing Ignite with affinity colocation, near caches should not be used. If computations are collocated with the corresponding partition cache nodes then the near cache is simply not needed because all the data is available locally in the partitioned cache. However, there are cases when it is simply impossible to send computations to remote nodes. For cases like this near caches can significantly improve scalability and the overall performance of the application.

Transactions

Near caches are fully transactional and get updated or invalidated automatically whenever the data changes on the servers.

Near Caches on Server Nodes

Whenever accessing data from PARTITIONED caches on the server side in a non-collocated fashion, you may need to configure near-caches on the server nodes via CacheConfiguration.setNearConfiguration(...) property.

Configuration

Most configuration parameters available on CacheConfiguration that make sense for the near cache are inherited from the server configuration. For example, if the server cache has an ExpiryPolicy, entries in the near cache will be expired based on the same policy.

Parameters listed in the table below are not inherited from the server configuration and provided separately, via the NearCacheConfiguration object.

Setter Method
Description
Default

setNearEvictionPolicy(CacheEvictionPolicy)

Eviction policy for the near cache.

None

setNearStartSize(int)

Start size for near cache.

375,000