Este conteúdo não está disponível no idioma selecionado.

Chapter 8. Defining File-based Cache Stores


Define a file-based cache store with datagrid-service to persist data to external storage.

Use the XMLStringConfiguration class to provide XML configuration as a string through the Hot Rod interface.

  • XML must be valid with the Data Grid configuration schema.
  • Location of your file store should be under the storage volume mounted at /opt/datagrid/standalone/data because the data folder is a PersistentVolume that allows data to survive when the container restarts.

As an example, the following main method creates a cache with a distributed configuration that includes a file store:

public static void main(String[] args) {

   ConfigurationBuilder cfg = ...

   RemoteCacheManager rcm = new RemoteCacheManager(build);

   String xml = String.format(
      "<infinispan>" +
         "<cache-container>" +
            "<distributed-cache name=\"%1$s\">" +
               "<persistence passivation=\"false\">" +
                  "<file-store " +
                     "shared=\"false\" " +
                     "fetch-state=\"true\" " +
                     "path=\"${jboss.server.data.dir}/datagrid-infinispan/%1$s\"" +
                  "/>" +
               "</persistence>" +
            "</distributed-cache>" +
         "</cache-container>" +
      "</infinispan>",
      "cacheName"
   );

   RemoteCache<Object, Object> index = rcm.administration()
   //Include a flag to make the cache permanent.
   .withFlags(CacheContainerAdmin.AdminFlag.PERMANENT)
   //Create a cache with the XML configuration
   .createCache("cacheName", new XMLStringConfiguration(xml));

   System.out.println(index.size());

}
Copy to Clipboard Toggle word wrap

For information about valid file-store configuration options, see the Data Grid configuration schema.

See the Javadocs for more information:

Voltar ao topo
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2025 Red Hat