Este contenido no está disponible en el idioma seleccionado.

35.2. Configuring Near Caches


Near caching can be enabled and disabled via configuration without making any changes to the Hot Rod Client application. To enable near caching, configure the near caching mode (Eager or Lazy) on the client and optionally specify the number of entries to be kept in the cache.
Near cache mode is configured using the NearCacheMode enumeration.
The following example demonstrates how to configure Lazy near cache mode.

Example 35.1. Configuring Lazy Near Cache Mode

import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.NearCacheMode;
…

ConfigurationBuilder lazy = new ConfigurationBuilder();
lazy.nearCache().mode(NearCacheMode.LAZY).maxEntries(10);
The following example demonstrates how to configure Eager near cache mode.

Example 35.2. Configuring Eager Near Cache Mode

import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.NearCacheMode;
...

ConfigurationBuilder eager = new ConfigurationBuilder();
eager.nearCache().mode(NearCacheMode.EAGER)..maxEntries(10);

Note

Near cache size is unlimited by default but it can be changed to set a maximum size in terms of number of entries for the near cache. When the maximum size is reached, near cached entries are evicted using a least-recently-used (LRU) algorithm.

Example 35.3. Configuring Near Cache Maximum Size

import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
...

ConfigurationBuilder builder = new ConfigurationBuilder();
builder.nearCache().maxEntries(100);
Here, 100 is the maximum number of entries to keep in the near cache.

Note

This configuration also results in a disabled near cache mode when no mode is specified.
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.