Skip to content

Instantly share code, notes, and snippets.

@hodrigohamalho
Last active June 8, 2016 19:04
Show Gist options
  • Select an option

  • Save hodrigohamalho/97142c7e6669fe18f05a6b9936bab48b to your computer and use it in GitHub Desktop.

Select an option

Save hodrigohamalho/97142c7e6669fe18f05a6b9936bab48b to your computer and use it in GitHub Desktop.
JBoss Data Grid

Remote Cache

Add Hotrod dependency

<dependency>
  <groupId>org.infinispan</groupId>
  <artifactId>infinispan-client-hotrod</artifactId>
</dependency>

Configuration Builder

  1. Cria o Configuration usando o ConfigurationBuilder

  2. Cria o RemoteCacheManager passando como parametro o Configuration criado anteriormente

    Configuration config = new ConfigurationBuilder()
               .addServer()
                  .host("localhost")
                  .port(11222)
               .build();
    RemoteCacheManager cacheManager = new RemoteCacheManager(config);
    RemoteCache<String,Integer> cache = cacheManager.getCache(); // use default cache

Se houver vários servers pode utilizar o .addServers(hostname:porta,outro-hostname:port)

Tomar cuidado com o uso de keySet( ) durante o uso de cache distribuido

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment