cache2k 2.0.0.Final “North Atlantic”
This change log lists the complete changes since the last stable version 1.6.0.Final.
Upgrading from version 1
Version 2 has breaking changes. Recompilation is required. Most code will run with minor or no modifications. Common used functionality was kept or will be replaced gradually via deprecation. Deprecated elements may be removed in a version 2 minor release. Asses your code and change deprecated usages to the suggested alternative to be compatible with future releases.
Major changes:
- Requires at least Java 8 to run
- JMX and XML configuration support is no longer part of
cache2k-core - No caching of exceptions by default. This has to be enabled explicitly by specifying
ResiliencePolicy. Previous default resilience available asUniversalResiliencePolicyincache2k-addon
New and Noteworthy
cache2k now requires at least Java 8. This release focusses on API cleanup and touch ups with adaptions to available Java 8 concepts (e.g. CompetebleFuture or Duration). No major functionality was added.
- cache2k-api, cache2k-core, cache2k-jmx and cache2k-config are fully modularized
- Requires at least Java 8 to run
- Adaptions to Java 8 on API level. E.g. use of Duration in the configuration
- New interfaces for
CacheLoaderandCacheWriterin packageorg.cache2k.io - Removal of deprecated classes and methods
- JMX and XML configuration support is no longer part of
cache2k-core - OSGi support with
cache2k-osgi-allremoved, see: GH#83 @Nullableannotations with Kotlin native type support- General scheme to enable extra functionality (
Feature), used for JMX and Micrometer support - No caching of exceptions by default. This has to be enabled explicitly by specifying
ResiliencePolicy. Previous default resilience available asUniversalResiliencePolicyincache2k-addon - Configuration: Functionality can be bundled in features and can augment the configuration and wrap the cache instance.
Possible Breakages
Since this is a major release, some rarely used things in the API are changed without backwards compatibility. Most code is supposed to run without breaking.
- Requires at least Java 8 to run
- Remove deprecated classes and methods:
Cache.prefetch,Cache.prefetchAll,IntCache,LongCache,CacheEntry.getLastModification,AbstractCacheEntry - Incompatible change of
CustomizationSupplierinterface org.cache2k.integration.ResiliencePolicyremoved. Replaced by:org.cache2k.io.ResiliencePolicy- JMX support moved from
cache2k-coretocache2k-jmxto minimize module dependencies - XML configuration moved from
cache2k-coretocache2k-configto minimize module dependencies - Dropped apache commons logging support. Commons logging seems to be not maintained any more and lacks Jigsaw/module support.
- Drop support for XML configuration on Android, removed XML pull dependency (The Android will be potentially unsupported in cache2k V2 at first)
- Moved JCache configuration classes in
org.cache.jcachefromcache2k-apitocache2k-jcache. If these are used,cache2k-jcacheneeds to be in compile scope. Cache2kConfiguration: Changed all parameters of type long, representing milliseconds to typeDuration- Remove deprecated classes and methods:
Cache.prefetch,Cache.prefetchAll,IntCache,LongCache,CacheEntry.getLastModification,AbstractCacheEntry Cache.getStatisticsremoved. Replaced byCacheManagement.of(Cache).sampleStatistics().Cache.clearAndCloseremoved. Replaced byCacheManagement.destroy- Removed deprecated
MutableCacheEntry.getCurrentTime, replaced withgetStartTime - Remove
MutableCacheEntry.wasExistingandMutableCacheEntry.getOldValue - Rename
MutableCacheEntry.getRefreshedTimetogetModificationTime MutableCacheEntry.exists: Does not change the value aftersetValueor triggered loadMutableCacheEntry.getValue: Does not change the value aftersetValue- Every class with
Configurationshortened toConfigand consequently changed the package nameorg.cache2k.configurationtoorg.cache2k.config. Cache2kBuilder.toConfiguration()renamed toconfig()- Lots restructuring around the extra configuration sections and customizations
- remove
Cache2kBuilder.enableJmx. Replaced withCache2kBuilder.enable(JmxSupport.class) Cache.requestInterfacethrowsUnsupportedOperationExceptionif the requested interface is not supported instead of null- Change in special expiry values semantics:
ExpiryTimeValues.NO_CACHEremoved.ExpiryTimeValues.NOWdoes not start a refresh and expire immediately.ExpiryTimeValues.REFRESHdoes expire and start a refresh if refresh ahead is enabled. - No caching of exceptions by default. This has to be enabled explicitly by specifying
ResiliencePolicy. Previous default resilience available asUniversalResiliencePolicyincache2k-addon - Move
Weigherto packageorg.cache2k.operation. - Rename
MutableCacheEntry.reloadtoMutableCacheEntry.load - Remove
Cache2kBuilder.enableJmx
API Changes
org.cache2k.integration.CacheLoaderand everything in packageorg.cache2k.integrationis deprecated. Replacements are available inorg.cache2k.io. This major change was done to change from abstract classes to interface. The new package was introduced for smoother transition to keep the previous classes and deprecated them.- Move
TimeReferencetoorg.cache2k.operationand also makeScheduleravailable Cache2kBuilder: New methodssetupandenable- New method:
Cache.computeIfAbsentwith function - New methods
Cache.loadAllandCache.reloadAllwhich returnCompletableFutureOld methods which useCacheOperationCompletionListenerare deprecated - New methods:
Cache.mutate,Cache.mutateAllfor a mutation only entry processor variant Cache.entriesandCache.keysreturn aSetfor iteration and stream support- New method
CacheEntry.getExceptionInfo() org.cache2k.jmx, API for JMX MXBeans removed- New interfaces
CacheOperation,CacheControlandCacheInfoinorg.cache2k.operation - New method:
MutableCacheEntry.getExpiryTime() - New method:
MutableCacheEntry.setExpiryTime() - New method:
MutableCacheEntry.lock - Lots of generic typing refinements
- Allow listeners to throw a checked exception
@Nullable,@NonNullannotations- Deprecated
AdvancedKeyValueSourceandKeyValueStore
Fixes and Improvements
- All cache customizations (e.g.
CacheLoader) implementCustomization. - Speedup of internal hash table, because compatibility for Java 6 could be removed
Cache.loadAll()andCache.reloadAll()complete with exception if a a loader exception happened. If more than one exception happened the one is propagated.- Improved interface of
ExceptionPropagatorandLoadExceptionInfo, ACacheEntrymay be cast toLoadExceptionInfoif an exception is present Cache.invoke,EntryProcessor: Make expiry calculations and listeners calls more consistent if expiry event races with the start of the operationMutableCacheEntry.lockallows to lock an entry for mutation explicitlyCache.asMap/ConcurrentMapimplementation implements compute methods and runs them only once- Introduced
ConfigAugmenterwhich can make changed to the configuration before a cache is build Cache2kBuilder: Methodssetup,applyallow to execute a function on the configuration or builder, which can be used to factor out configuration fragments. We use this to provideenableanddisablemethods on policies.- AdvancedCacheLoader, AsyncCacheLoader and ExpiryPolicy get null if current entry carries exception, https://github.com/cache2k/cache2k/issues/163
- Remove
ServiceLoaderin modulescache2k-jmxandcache2k-micrometer - Introduce concept of
CacheFeatureandToggleCacheFeature CacheType: immutable instead of bean.CacheType.ofmoved fromCacheTypeCapture- Remove the need of serializable from the configuration objects, by doing a deep copy of the default configuration via bean setters and getters.
Cache2kConfig: MakesetEternala separate flag. Remove logic from setters, so we can use setters and getter to copy the object- Ignore
entryCapacitysetting in case a weigher is specified - Cap suppression or caching of exceptions determined by
ResiliencePolicyto theexpireAfterWriteduration, if specified - Fix site build for Java 11
- Documentation touch ups
- Change configuration XML schema to version 2 and archive version 1
- Spring cache manager applies default setup also to dynamically created caches that are retrieved via
getCache