You can retrieve a local or distributed CacheManager instance from the WebSphere® eXtreme Scale caching provider. A CacheManager instance is like an eXtreme Scale ObjectGrid instance. Section 4 of the JCache API
provides information about cache managers and the behavior of the CacheManager API.
Procedure
-
Create a local-only CacheManager instance.
Note: A local instance is on the same Java™ virtual machine (JVM) as
the client. In local mode, everything runs in a single JVM.
- To create a new CacheManager named
DEFAULT with no caches configured:
CacheManager localWXSManager = wxsProvider.getCacheManager();
- To create a new CacheManager named
wxsCacheManager with no caches configured:
CacheManager localWXSManager = wxsProvider.getCacheManager(CachingProviderImpl.createLocalURI("wxsCacheManager", null);
- To create a new CacheManager named
existingCacheManager based on an existing
objectGrid.xml file that is at /opt/objectGrid.xml:
URI objectGridXML = new File("/opt/objectGrid.xml").toURI();
Properties props = new Properties();
props.put(CachingProviderImpl.PROP_LOCAL_CACHE_XML_URI, objectGridXML);
CacheManager existingCacheManager = wxsProvider.getCacheManager(CachingProviderImpl.createLocalURI("myOG"), null, props);
For
this example, the objectGrid.xml must define an ObjectGrid named
myOG.
-
Create a distributed CacheManager instance.
Note: A distributed instance is remote. In remote mode, configure catalog and
containers servers on one or more remote locations.
To create a distributed CacheManager instance, retrieve a remote CacheManager instance. An
existing distributed eXtreme Scale configuration must be
running.
- To retrieve a remote CacheManager with a client that runs in a stand-alone JVM, you can use a
Properties object with
PROP_CATALOG_END_POINTS:
URI clientCacheManagerURI = CachingProviderImpl.createClientURI("myDistributedOG", null, null);
Properties props = new Properties();
props.put(CachingProviderImpl.PROP_CATALOG_END_POINTS, "myHost1:2809,myHost2:2809,myHost3:2809");
CacheManager wxsDistributedCacheManager = wxsProvider.getCacheManager(clientCacheManagerURI, null, props);
For
this example, the catalog service end points of the configuration are myHost1:2809,
myHost2:2809, and myHost3:2809. Also, an ObjectGrid named
myDistributedOG must exist.
- To retrieve a remote CacheManager with a client that runs in a WebSphere Application Server or Liberty JVM, you can use a configured catalog service
domain:
URI clientCacheManagerURI = CachingProviderImpl.createClientURI("myDistributedOG", "myCatDomain", null);
CacheManager wxsDistributedCacheManager = wxsProvider.getCacheManager(clientCacheManagerURI, null, null);
For
this example, a catalog service domain that is named myCatDomain and an ObjectGrid
named myDistributedOG must exist. The Properties object with
PROP_CATALOG_END_POINTS is not necessary because the catalog service domain already contains that
connection information, including any security configuration.
What to do next
After you create a CacheManager instance, you can access a previously defined cache, create a new
cache, or delete an existing cache.