Fork me on GitHub

cache2k 2.6.0.Final “Cogee Beach”

This change log lists the changes since 2.4.1.Final.

New and Noteworthy

  • Idle scan: an efficient expire after access / time to idle alternative, Github issue #39
  • Lots of cleanup and housekeeping with some minor changes possibly breaking compatibility
  • Test coverage improvement and removal of unused code
  • Cache disable support, Github issue #74
  • Continuous Android testing

Updated benchmarks comparing with Caffeine 3.0.5, and EHCache3 3.9.6

Possible breakages

Changes that may break existing applications.

  • Spring support: SpringCache2kManager.defaultSetup throws IllegalStateException if not called before caches are added
  • Spring support: SpringCache2kManager.defaultSetup throws IllegalStateException if called twice
  • EXPIRY_NOT_ETERNAL constant removed from Cache2kConfig
  • Fixed generic typing issues in org.cache2k.config package
  • Sechduler.schedule uses delay duration instead of absolute time
  • TimeReference.millis() renamed to ticks() and additional conversion methods to support other time resolutions than milliseconds
  • Safety gap system property for sharp timeout changed to: org.cache2k.sharpExpirySafetyGapMillis
  • Removed capability to modify internal constants via Tunable
  • removed SpringCache2kCacheManager.setCaches(Collection<Cache2kConfig<?, ?>> cacheConfigurationList)
  • Corrected signature BulkCacheLoader.BulkCallback.onLoadFailure(Set, Exception) to onLoadFailure(Iterable, Exception)
  • Cache.expireAt() and MutableCacheEntry.setExpiryTime(): the maximum expiry time is capped by the specified expireAfterWriteDuration, this aligns the behavior with the ExpiryPolicy. The rationale is, that an (application) user, when setting expireAfterWrite expects that this duration is never exceeded.

API Changes

  • Added CacheClosedException
  • Added CacheEventListenerException

Fixes and Improvements

  • Eviction improvements, minimal change to improve eviction, See issue comment
  • eternal(true/false) / MutableEntry.setExpiryTime: Expiry can be modified, although no other expiry setting is present, or in other words: the timer support is available by default. If eternal(true) is configured, timer support is disabled and Cache.invoke / MutableEntry.setExpiryTime or Cache.expireAt cannot be used
  • Cache.invoke / MutableEntry.setExpiryTime: has no effect if entry is not existing
  • Cache.invoke / MutableEntry.getExpiryTime always returns positive time value
  • CI tests with Android API level 26 and API level 30
  • Expiry timer: handle time values close up to Long.MAX_VALUE - 1 without overflow
  • Support Duration for duration parameters in the Cache2kBuilder
  • Config section InternalConfig in cache2k-core for specific tuning values that should not be exposed in the public API
  • Spring support: SpringCache2kManager.setDefaultCacheNames() added
  • Spring support: SpringCache2kManager.addCache(String, Function)
  • Spring support: SpringCache2kCacheManager.getCache aligned with interface contract: returns null if unknown cache name is requested
  • CacheClosedListener: Wait for CompletableFuture
  • Simplify integrity checking, remove integrity state from toString output
  • API: add/correct @Nullable annotations in ExpiryPolicy and AsyncCacheLoader
  • Cache.invoke: Set expiry time correctly for exception propagation, in case setException and setExpiry is used atomically
  • CacheInfo.getExpiryAfterWriteTicks, CacheInfo.getTimeReference(): added
  • CacheControl.getCapacityLimit returns maximum weight correctly when weigher is present
  • JCache: simplify implementation with access expiry and Cache.getAll
  • JCache: Corrected access expiry handling for Cache.invoke / Cache.invokeAll

Non Functional Improvements

  • Some tests migrated to JUnit 5 and AspectJ
  • Various documentation touch ups
  • Documentation and examples for expiry and expiry policy
  • Examples for expiry policy in ExpiryPolicyExampleTest unit test
  • Documentation improvements, fixed many typos and grammar errors in the API package

Credits

Using this cache2k version

The binaries are available on maven central.

For Java SE/EE and Android environments

For Maven users:

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>cache2k-api</artifactId>
      <version>2.6.0.Final</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>cache2k-core</artifactId>
      <version>2.6.0.Final</version>
      <scope>runtime</scope>
    </dependency>

For Gradle users:

def cache2kVersion = '2.6.0.Final'

dependencies {
    implementation "org.cache2k:cache2k-api:${cache2kVersion}"
    runtimeOnly "org.cache2k:cache2k-core:${cache2kVersion}"
}

Using the JCache / JSR107 provider

Maven users include the cache2k JCache provider this way:

    <dependency>
      <groupId>org.cache2k</groupId>
      <artifactId>cache2k-jcache</artifactId>
      <version>2.6.0.Final</version>
      <scope>runtime</scope>
    </dependency>

For Gradle users:

dependencies {
    runtimeOnly "org.cache2k:cache2k-jcache:2.6.0.Final"
}

Implementation details, tuning tips and hints on configuration can be found at: JCache - cache2k User Guide