Blogs Hot Rod per-cache configuration

Hot Rod per-cache configuration

Aside from being able to configure a Java Hot Rod client through a compact URI representation, Infinispan 11 brings some additional changes to remote cache configuration.

While remote caches did have some client-side configuration, this was never implemented cleanly, resorting to multiple overloaded variations on the getCache() method, for example to obtain a transactional cache, or enabling near-caching.

Infinispan 11 now allows specifying per-cache configuration both through the API and through the declarative properties file.

Let’s look at a few examples.

ConfigurationBuilder builder = new ConfigurationBuilder()
RemoteCacheManager manager = new RemoteCacheManager(;

In the above code snippet, we enable near-caching for the cache closecache and we enable NON_XA transactions on the cache txcache.

The equivalent file:


Automatic cache creation

A neat feature that has been implemented as part of per-cache configuration, is the ability to automatically create a cache on the server on first use, if it is missing, by supplying either an existing template or a full-blown configuration.

ConfigurationBuilder builder = new ConfigurationBuilder()
RemoteCacheManager manager = new RemoteCacheManager(;
Cache<String, String> cache = manager.getCache("mydistcache");

The above example using a properties file would look like:


Get it, Use it, Ask us!

We’re hard at work on new features, improvements and fixes, so watch this space for more announcements!

Please, download and test the latest release.

The source code is hosted on GitHub. If you need to report a bug or request a new feature, look for a similar one on our JIRA issues tracker. If you don’t find any, create a new issue.

If you have questions, are experiencing a bug or want advice on using Infinispan, you can use StackOverflow. We will do our best to answer you as soon as we can.

The Infinispan community uses Zulip for real-time communications. Join us using either a web-browser or a dedicated application on the Infinispan chat.

Tristan Tarrant

Tristan has been leading the Infinispan Engineering Team at Red Hat for the past five years as well as being Principal Architect for Red Hat Data Grid. He’s been a passionate open-source advocate and contributor for nearly three decades.