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 asUniversalResiliencePolicy
incache2k-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
CacheLoader
andCacheWriter
in 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-all
removed, see: GH#83 @Nullable
annotations 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 asUniversalResiliencePolicy
incache2k-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
CustomizationSupplier
interface org.cache2k.integration.ResiliencePolicy
removed. Replaced by:org.cache2k.io.ResiliencePolicy
- JMX support moved from
cache2k-core
tocache2k-jmx
to minimize module dependencies - XML configuration moved from
cache2k-core
tocache2k-config
to 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.jcache
fromcache2k-api
tocache2k-jcache
. If these are used,cache2k-jcache
needs 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.getStatistics
removed. Replaced byCacheManagement.of(Cache).sampleStatistics()
.Cache.clearAndClose
removed. Replaced byCacheManagement.destroy
- Removed deprecated
MutableCacheEntry.getCurrentTime
, replaced withgetStartTime
- Remove
MutableCacheEntry.wasExisting
andMutableCacheEntry.getOldValue
- Rename
MutableCacheEntry.getRefreshedTime
togetModificationTime
MutableCacheEntry.exists
: Does not change the value aftersetValue
or triggered loadMutableCacheEntry.getValue
: Does not change the value aftersetValue
- Every class with
Configuration
shortened toConfig
and consequently changed the package nameorg.cache2k.configuration
toorg.cache2k.config
. Cache2kBuilder.toConfiguration()
renamed toconfig()
- Lots restructuring around the extra configuration sections and customizations
- remove
Cache2kBuilder.enableJmx
. Replaced withCache2kBuilder.enable(JmxSupport.class)
Cache.requestInterface
throwsUnsupportedOperationException
if the requested interface is not supported instead of null- Change in special expiry values semantics:
ExpiryTimeValues.NO_CACHE
removed.ExpiryTimeValues.NOW
does not start a refresh and expire immediately.ExpiryTimeValues.REFRESH
does 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 asUniversalResiliencePolicy
incache2k-addon
- Move
Weigher
to packageorg.cache2k.operation
. - Rename
MutableCacheEntry.reload
toMutableCacheEntry.load
- Remove
Cache2kBuilder.enableJmx
API Changes
org.cache2k.integration.CacheLoader
and everything in packageorg.cache2k.integration
is 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
TimeReference
toorg.cache2k.operation
and also makeScheduler
available Cache2kBuilder
: New methodssetup
andenable
- New method:
Cache.computeIfAbsent
with function - New methods
Cache.loadAll
andCache.reloadAll
which returnCompletableFuture
Old methods which useCacheOperationCompletionListener
are deprecated - New methods:
Cache.mutate
,Cache.mutateAll
for a mutation only entry processor variant Cache.entries
andCache.keys
return aSet
for iteration and stream support- New method
CacheEntry.getExceptionInfo()
org.cache2k.jmx
, API for JMX MXBeans removed- New interfaces
CacheOperation
,CacheControl
andCacheInfo
inorg.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
,@NonNull
annotations- Deprecated
AdvancedKeyValueSource
andKeyValueStore
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
ExceptionPropagator
andLoadExceptionInfo
, ACacheEntry
may be cast toLoadExceptionInfo
if 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.lock
allows to lock an entry for mutation explicitlyCache.asMap
/ConcurrentMap
implementation implements compute methods and runs them only once- Introduced
ConfigAugmenter
which can make changed to the configuration before a cache is build Cache2kBuilder
: Methodssetup
,apply
allow to execute a function on the configuration or builder, which can be used to factor out configuration fragments. We use this to provideenable
anddisable
methods on policies.- AdvancedCacheLoader, AsyncCacheLoader and ExpiryPolicy get null if current entry carries exception, https://github.com/cache2k/cache2k/issues/163
- Remove
ServiceLoader
in modulescache2k-jmx
andcache2k-micrometer
- Introduce concept of
CacheFeature
andToggleCacheFeature
CacheType
: immutable instead of bean.CacheType.of
moved 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
: MakesetEternal
a separate flag. Remove logic from setters, so we can use setters and getter to copy the object- Ignore
entryCapacity
setting in case a weigher is specified - Cap suppression or caching of exceptions determined by
ResiliencePolicy
to theexpireAfterWrite
duration, 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