cache2k version 0.27-BETA “Fort Lauderdale”
New and Noteworthy
A lot of API movement, since we work towards 1.0. See Potential breakages and API changes. The API is not completely stable yet, but almost.
- Use of Java 8 features (StampedLock), when available, to improve performance of cache mutations
- Eviction allows segmentation, to improve multi core performance of insert and remove operations on the cache (
Cache2kBuilder.evictionSegmentCount) - Various other performance improvements
- Lots of work on the documentation. Not yet published. See the GitHub source
Potential breakages
Changes in semantics or API that may break existing applications are listed here. Modifications in the statistics output will not listed as breakage.
- null values are not allowed (any more!) by default. The use of a null value can be enabled again via
permitNullValues. The old deprecated builder (CacheBuilder) configures the cache to permit null values by default to be backwards compatible to applications still using the version 0.20-ish interfaces. - LoadCompletedListener renamed to CacheOperationCompletionListener
Cache.loadandCache.reload: Signature change, swap the two parametersCache.invokeandCache.invokeAll: Remove var arg argument for arbitrary objects. Better aligned to Java 8 lambdas.
Bug fixes
If something is listed here it might affect an existing application and updating is recommended.
Fixes and Improvements
getAll()returns a stable map, not affected by expiry and parallel cache modifications.- Fixed possible inconsistency between
CacheEntry.getValue()andCacheEntry.getLastModification(), when concurrent update happens - Eviction implementation cleanup and simplification
- JCache: Custom classloader used for serialization of keys and values
- JCache: improved performance when not using custom expiry policy
- JCache: extended configuration of cache2k features via JCache is possible
- Exceptions in the expiry policy and resilience policy will be propagated as
CacheLoaderExceptionif happened during load - asMap() provided
ConcurrentMapinterface view of the cache - Reduce memory footprint: history size of Clock-Pro eviction reduced to one half of the capacity
getAll()returns empty map if no loader is defined and requested keys are not in cacheget()returnnullif no loader is defined and entry is not in cache (was exception before).CacheEntry.getValue()andMutableCacheEntry.getValue()throws exception if loader exception happenedCache.invoke: Exceptions from entry processor propagated correctly asEntryProcessingException- Global
ExceptionPropagatorcustomizable via tunable mechanism. CacheEntryProcessorrenamed toEntryProcessorCacheEntryProcessingExceptionrenamed toEntryProcessingExceptionCache2kBuilder.keepDataAfterExpired: has become false by defaultEntryProcessor: Triggers load whenMutableEntry.getExceptionis calledEntryProcessor:MutableEntry.setExceptionorMutableEntry.setExpirywork correctly after loading the value- Statistics: Correct usage counter in case of a race at entry mutation
new Cache2kBuilder(){}, yields proper exception instead of justClassCastExceptionnew Cache2kBuilder<Object, Object>(){}, yieldsIllegalArgumentException, useCache2kBuilder.forUnkownTypes()- lots of internal cleanup
- Interface
ExpiryTimeValueswith constants for special expiry times
API Changes and new methods
contains()replaced withcontainsKey()expire()expires an entry manually or resets the expiry time- Rename:
CacheConfigurationtoCache2kConfiguration - Removed
clearTimingStatisticsoperation from JMX Cache.iterator()is deprecated, alternative isCache.entries()orCache.keys()Cache.invokeandCache.invokeAll: Remove var arg argument for arbitrary objects. Better aligned to Java 8 lambdas.
Using this cache2k version
For Java SE/EE environments
<dependency>
<groupId>org.cache2k</groupId>
<artifactId>cache2k-api</artifactId>
<version>0.27-BETA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.cache2k</groupId>
<artifactId>cache2k-all</artifactId>
<version>0.27-BETA</version>
<scope>runtime</scope>
</dependency>
For Android
<dependency>
<groupId>org.cache2k</groupId>
<artifactId>cache2k-api</artifactId>
<version>0.27-BETA</version>
</dependency>
<dependency>
<groupId>org.cache2k</groupId>
<artifactId>cache2k-core</artifactId>
<version>0.27-BETA</version>
<scope>runtime</scope>
</dependency>
Using the JCache / JSR107 provider
<dependency>
<groupId>org.cache2k</groupId>
<artifactId>cache2k-jcache</artifactId>
<version>0.27-BETA</version>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.0.0</version>
</dependency>