Fork me on GitHub

cache2k 1.1.2.Alpha

This version is a development preview and not recommended for production use. Please give feedback to help stabilize and improve the next version.

New and Noteworthy

  • Optimized cache version for integer keys with better memory footprint and access performance since no autoboxing is needed.
  • Support for Spring caching abstraction. See the user guide on Spring Framework Integration

API Changes

  • IntCache and LongCache for int and long keys, plus IntKeyValueSource and LongKeyValueSource
  • Cache2kBuilder.getManager() returns the cache manager
  • Cache.computeIfAbsent propagates RuntimeException without wrapping

Fixes and Improvements

  • Code quality: Unused code removed, various tests with simulated clock for expiry and refresh added
  • CacheEntry.getLastModificationTime() throws exception if this functionality is disabled
  • skip time recording correctly when disableLastModificationTime is set
  • Remove SimpleCacheEntry introduced before in 1.1.1.Aplha since this bloats the API
  • Rename thread prefrix for async listener execution from cache2k-async to cache2k-listener
  • Add CacheManager.getConfiguredCacheNames to get a list of caches that are specified in the XML configuration
  • JCache: If a cache is present in the XML configuration CacheManager.getCache creates the cache based on the present configuration. Some clients (e.g. Spring) use CacheManager.getCache to request an exiting/known cache.
  • JCache: ignore isWriteThrough flag and just use the writer when present. This avoids an NPE if a cache client enables write through but does not provide a writer (as found in datanucleus).
  • Cache.replaceIfEquals: Fix potential NPE, if listener or writer is used

Using this cache2k version

For Java SE/EE and Android environments

    <dependency>
      <groupId>org.cache2k</groupId>
      <artifactId>cache2k-api</artifactId>
      <version>1.1.2.Alpha</version>
    </dependency>
    <dependency>
      <groupId>org.cache2k</groupId>
      <artifactId>cache2k-impl</artifactId>
      <version>1.1.2.Alpha</version>
      <scope>runtime</scope>
    </dependency>

Note to Android users: The cache2k-impl contains code that might only be needed in server environments (e.g. JMX support). If not needed, it is possible to strip unnecessary code. Example ProGuard rules can be found at cache2k user guide - Android secion

Using the JCache / JSR107 provider

    <dependency>
      <groupId>org.cache2k</groupId>
      <artifactId>cache2k-jcache</artifactId>
      <version>1.1.2.Alpha</version>
    </dependency>
    <dependency>
      <groupId>javax.cache</groupId>
      <artifactId>cache-api</artifactId>
      <version>1.1.0</version>
    </dependency>