Configuration
This is the manual for older MicroStream versions (Version < 5.0).
The new documentation (Version >= 5.0) is located at:
The default way to configure a JCache provider is to use the classjavax.cache.configuration.MutableConfiguration. This is mostly used to avoid provider specific code.
If you want to use all of MicroStream's Cache features, you can use our configuration implementation: one.microstream.cache.CacheConfiguration
1
CachingProvider provider = Caching.getCachingProvider();
2
CacheManager cacheManager = provider.getCacheManager();
3
CacheConfiguration<Integer, String> configuration = CacheConfiguration
4
.Builder(Integer.class, String.class)
5
.storeByValue()
6
.expiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ONE_MINUTE))
7
.build();
8
Cache<Integer, String> cache = cacheManager.createCache("jCache", configuration);
9
cache.put(1, "Hello World");
10
String value = cache.get(1);
Copied!
To read an external configuration use CacheConfigurationLoader and CacheConfigurationParser or the Load*() methods of CacheConfiguration.
1
CacheConfiguration<Integer, String> configuration = CacheConfiguration
2
.Load("cache-config.properties", Integer.class, String.class);
Copied!
If you just use CacheConfiguration.Load() the default configuration file is used, which is either a file in the classpath root named microstream-cache.properties, or the path configured via the system property microstream.cache.configuration.path.
Last modified 3mo ago
Export as PDF
Copy link