cache2k version 0.25-BETA “Indian Shores”
New and Noteworthy
A lot of API movement, since we work towards 1.0. See Potential breakages
and API changes
. The API is not stable yet.
New builder class Cache2kBuilder
. A cache is now built the following way:
Cache<Long, List<String>> c = new Cache2kBuilder<Long, List<String>>() {} .name("myCache") .eternal(true) .build();
The new pattern allows to capture the complete type information. For compatibility reasons the old builder class CacheBuilder
is still available to allow applications to transition to the new builder.
New features:
- Asynchronous entry operation events
Potential breakages
Changes in semantics or API that may break existing applications are listed here. In general, only very minor changes are done with breaking existing semantics, which will most likely not affect existing applications. Everything that will most likely break applications will be introduced as a new API and the old one will get deprecated. Modifications in the statistics output will not listed as breakage.
- Either expiryDuration or eternal must be set explicitly in this release. See: https://github.com/cache2k/cache2k/issues/21
- Return value of
Cache.iterator()
changed fromClosableIterator
toIterator
ExperimentalBulkCacheSource
removed- CacheConfig and other configuration related things renamed and moved to subpackage configuration
- Thread numbers from generated threads start with 1 and numbers will be reused if thread dies
- Interface ClosableIterator removed
Bug fixes
If something is listed here it might affect an existing application and updating is recommended.
- Fix a potential race condition: timer event / entry update
- Deriving a cache name in a static class constructor failed, https://github.com/cache2k/cache2k/issues/47
- Fix a memory leak manifesting at high eviction rates and with expiry
- Fix for JMX naming: Duplicate names got disambiguated, but JMX used the original name (fix for current behavior, how cache names are handled will be finally changed and documented in the upcoming releases)
Fixes and Improvements
Fixes of corner cases that are most likely not affecting any existing applications and improvements are listed here.
- JavaDoc improvements (ongoing…)
CacheManager.getCache()
does not return a closed or uninitialized cache- Make the iterator more robust. Problems with the previous solution: The iterator could block the cache if the iteration is not finished completely or the iterator was not closed. In case of concurrent updates to the cache the iterator could continue iterating as long as entries are inserted.
- Automatically generated cache names get a random number and start with ‘_’, more see:
Cache2kBuilder.name
- JDK Logging: prevent loggers own class name to be logged
API Changes and new methods
- Return value of
Cache.iterator()
changed fromClosableIterator
toIterator
Cache2kBuilder
as replacement forCacheBuilder
Cache2kBuilder.name(Class)
sets the fully qualified class name as nameCache2kBuilder.expiryAfterWrite()
is the replacement of:CacheBuilder.expiryDuration()
- Option
keepDataAfterExpired
renamed tokeepValueAfterExpired
Cache2kBuilder.addAsyncListener
CacheConfiguration.writer
CacheConfiguration.getListeners
CacheConfiguration.getAsyncListeners
KeyValueStore
AdvancedKeyValueSource
Using this cache2k version
For Java SE/EE environments
<dependency> <groupId>org.cache2k</groupId> <artifactId>cache2k-api</artifactId> <version>0.25-BETA</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.cache2k</groupId> <artifactId>cache2k-all</artifactId> <version>0.25-BETA</version> <scope>runtime</scope> </dependency>
For Android
<dependency> <groupId>org.cache2k</groupId> <artifactId>cache2k-api</artifactId> <version>0.25-BETA</version> </dependency> <dependency> <groupId>org.cache2k</groupId> <artifactId>cache2k-core</artifactId> <version>0.25-BETA</version> <scope>runtime</scope> </dependency>
Using the JCache / JSR107 provider
<dependency> <groupId>org.cache2k</groupId> <artifactId>cache2k-jcache</artifactId> <version>0.25-BETA</version> </dependency> <dependency> <groupId>javax.cache</groupId> <artifactId>cache-api</artifactId> <version>1.0.0</version> </dependency>