Remote Cache Aliases
What You Will Learn
How to add aliases to an existing remote cache so you can access the same cache data using alternative names.
Prerequisites
-
Java 17+
-
An Infinispan Server running on
localhost:11222(or Docker/Podman available for Testcontainers)
Step 1: Connect and Store Data
Connect to the server, obtain a remote cache, and store a value:
// Connect to the server
cacheManager = TutorialsConnectorHelper.connect();
// Obtain the remote cache
cache = cacheManager.getCache(TUTORIAL_CACHE_NAME);
// Store a value
cache.put("key", "value");
// Retrieve the value and print it out
System.out.printf("key = %s\n", cache.get("key"));
Step 2: Add and Use Aliases
Use the admin API to update the aliases configuration attribute. You can then access the same cache data through any of its aliases:
// Add aliases to the cache
cacheManager.administration().updateConfigurationAttribute(cache.getName(), "aliases", "alias alias2");
// Retrieve the value through an alias
cacheAlias = cacheManager.getCache("alias");
if (cacheAlias != null) {
System.out.printf("key = %s\n", cacheAlias.get("key"));
}
The alias points to the same underlying cache, so all data is shared.
Step 3: Run the Tutorial
mvn package exec:java
You should see output like:
key = value key = value
What’s Next
-
Create caches with the admin API
-
Get started with basic cache operations


