Fork me on GitHub

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 as UniversalResiliencePolicy in cache2k-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 and CacheWriter in package org.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 as UniversalResiliencePolicy in cache2k-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 to cache2k-jmx to minimize module dependencies
  • XML configuration moved from cache2k-core to cache2k-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 from cache2k-api to cache2k-jcache. If these are used, cache2k-jcache needs to be in compile scope.
  • Cache2kConfiguration: Changed all parameters of type long, representing milliseconds to type Duration
  • Remove deprecated classes and methods: Cache.prefetch, Cache.prefetchAll, IntCache, LongCache, CacheEntry.getLastModification, AbstractCacheEntry
  • Cache.getStatistics removed. Replaced by CacheManagement.of(Cache).sampleStatistics().
  • Cache.clearAndClose removed. Replaced by CacheManagement.destroy
  • Removed deprecated MutableCacheEntry.getCurrentTime, replaced with getStartTime
  • Remove MutableCacheEntry.wasExisting and MutableCacheEntry.getOldValue
  • Rename MutableCacheEntry.getRefreshedTime to getModificationTime
  • MutableCacheEntry.exists: Does not change the value after setValue or triggered load
  • MutableCacheEntry.getValue: Does not change the value after setValue
  • Every class with Configuration shortened to Config and consequently changed the package name org.cache2k.configuration to org.cache2k.config.
  • Cache2kBuilder.toConfiguration() renamed to config()
  • Lots restructuring around the extra configuration sections and customizations
  • remove Cache2kBuilder.enableJmx. Replaced with Cache2kBuilder.enable(JmxSupport.class)
  • Cache.requestInterface throws UnsupportedOperationException 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 as UniversalResiliencePolicy in cache2k-addon
  • Move Weigher to package org.cache2k.operation.
  • Rename MutableCacheEntry.reload to MutableCacheEntry.load
  • Remove Cache2kBuilder.enableJmx

API Changes

  • org.cache2k.integration.CacheLoader and everything in package org.cache2k.integration is deprecated. Replacements are available in org.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 to org.cache2k.operation and also make Scheduler available
  • Cache2kBuilder: New methods setup and enable
  • New method: Cache.computeIfAbsent with function
  • New methods Cache.loadAll and Cache.reloadAll which return CompletableFuture Old methods which use CacheOperationCompletionListener are deprecated
  • New methods: Cache.mutate, Cache.mutateAll for a mutation only entry processor variant
  • Cache.entries and Cache.keys return a Set for iteration and stream support
  • New method CacheEntry.getExceptionInfo()
  • org.cache2k.jmx, API for JMX MXBeans removed
  • New interfaces CacheOperation, CacheControl and CacheInfo in org.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 and KeyValueStore

Fixes and Improvements

  • All cache customizations (e.g. CacheLoader) implement Customization.
  • Speedup of internal hash table, because compatibility for Java 6 could be removed
  • Cache.loadAll() and Cache.reloadAll() complete with exception if a a loader exception happened. If more than one exception happened the one is propagated.
  • Improved interface of ExceptionPropagator and LoadExceptionInfo, A CacheEntry may be cast to LoadExceptionInfo 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 operation
  • MutableCacheEntry.lock allows to lock an entry for mutation explicitly
  • Cache.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: Methods setup, apply allow to execute a function on the configuration or builder, which can be used to factor out configuration fragments. We use this to provide enable and disable methods on policies.
  • AdvancedCacheLoader, AsyncCacheLoader and ExpiryPolicy get null if current entry carries exception, https://github.com/cache2k/cache2k/issues/163
  • Remove ServiceLoader in modules cache2k-jmx and cache2k-micrometer
  • Introduce concept of CacheFeature and ToggleCacheFeature
  • CacheType: immutable instead of bean. CacheType.of moved from CacheTypeCapture
  • Remove the need of serializable from the configuration objects, by doing a deep copy of the default configuration via bean setters and getters.
  • Cache2kConfig: Make setEternal 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 the expireAfterWrite 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