9.2. Create a local cache
import javax.cache.*; import javax.cache.configuration.*; // Retrieve the system wide cache manager CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); // Define a named cache with default JCache configuration Cache<String, String> cache = cacheManager.createCache("namedCache", new MutableConfiguration<String, String>());
storeByValue, so that object state mutations outside of operations to the cache, won’t have an impact in the objects stored in the cache. JBoss Data Grid has so far implemented this using serialization/marshalling to make copies to store in the cache, and that way adhere to the spec. Hence, if using default JCache configuration with Infinispan, data stored must be marshallable.
Cache<String, String> cache = cacheManager.createCache("namedCache", new MutableConfiguration<String, String>().setStoreByValue(false));
CacheManagermay be configured by specifying the location of a configuration file via the
CachingProvider.getCacheManager. This allows the opportunity to define clustered caches in a configuration file, and then obtain a reference to the preconfigured cache by passing the cache's name to the
CacheManager.getCachemethod; otherwise local caches can only be used, created from the
CacheManageris performed by passing standard HotRod client properties via
CachingProvider.getCacheManager. The remote servers referenced must be running and able to receive the request.
CacheManager.createCachemust be used so that the cache may be registered internally. Subsequent queries may be performed via