Fork me on GitHub

cache2k 2.4.0.Final “Port Philip”

This change log lists the changes since 2.2.1.Final.

New and Noteworthy

This targets details to improve performance of big caches in multi core environments and minimizing the CPU impact on monitoring and frequent statistic polls.

Updated benchmarks comparing with Caffeine 3.0.4, and EHCache3 3.9.6

Fixes and Improvements

  • Change default entry capacity to 1802. When the capacity is reported to a monitoring system or otherwise analysed, this serves as a magic number to indicate that the cache capacity is essentially not configured intentionally
  • Improved hit counter accuracy for statistics, see: https://github.com/cache2k/cache2k/issues/150
  • Improved statistics retrieval. When requesting the statistics, e.g. for micrometer export, no expensive operations are performed any more and no cache wide locking is done. In consequence statistics can be retrieved more frequently without big effect on the running application. Since there is no cache wide lock, statistics counters can have inconsistencies, e.g. the inserted and removed entries might not match exactly with the current size.
  • Eviction throughput improvement. The Clock-Pro ghost/history table is limited to 3K entries. Profiling showed that the big ghost table attributed to lower performance with bigger cache sizes (1 million entries) and did not contribute significantly to a better hitrate.
  • Various code quality improvements

API Breakages

  • MutableCacheEntry.getValueOrNull: removed, since wrongly introduced in version 2.0.

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.4.0.Final</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>cache2k-core</artifactId>
      <version>2.4.0.Final</version>
      <scope>runtime</scope>
    </dependency>

For Gradle users:

def cache2kVersion = '2.4.0.Final'

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

Note to Android users: The included jar files contain code that might only be needed in server environments (e.g. JMX support). It is possible to strip unnecessary code. Example ProGuard rules can be found at Andriod - cache2k User Guide

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.4.0.Final</version>
      <scope>runtime</scope>
    </dependency>

For Gradle users:

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

Implementation details, tuning tips and hints on configuration can be found at: [JCache - cache2k User Guide](https://cache2k.org/docs/latest/user-guide.html#jcache