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.defaultSetupthrowsIllegalStateExceptionif not called before caches are added - Spring support:
SpringCache2kManager.defaultSetupthrowsIllegalStateExceptionif called twice EXPIRY_NOT_ETERNALconstant removed fromCache2kConfig- Fixed generic typing issues in
org.cache2k.configpackage Sechduler.scheduleuses delay duration instead of absolute timeTimeReference.millis()renamed toticks()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)toonLoadFailure(Iterable, Exception) Cache.expireAt()andMutableCacheEntry.setExpiryTime(): the maximum expiry time is capped by the specifiedexpireAfterWriteDuration, this aligns the behavior with theExpiryPolicy. The rationale is, that an (application) user, when settingexpireAfterWriteexpects 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. Ifeternal(true)is configured, timer support is disabled andCache.invoke/MutableEntry.setExpiryTimeorCache.expireAtcannot be usedCache.invoke/MutableEntry.setExpiryTime: has no effect if entry is not existingCache.invoke/MutableEntry.getExpiryTimealways 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 - 1without overflow - Support
Durationfor duration parameters in theCache2kBuilder - Config section
InternalConfigincache2k-corefor 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.getCachealigned with interface contract: returnsnullif unknown cache name is requested CacheClosedListener: Wait forCompletableFuture- Simplify integrity checking, remove integrity state from toString output
- API: add/correct @Nullable annotations in
ExpiryPolicyandAsyncCacheLoader Cache.invoke: Set expiry time correctly for exception propagation, in casesetExceptionandsetExpiryis used atomicallyCacheInfo.getExpiryAfterWriteTicks,CacheInfo.getTimeReference(): addedCacheControl.getCapacityLimitreturns 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
ExpiryPolicyExampleTestunit test - Documentation improvements, fixed many typos and grammar errors in the API package
Credits
- Marcel Schnelle, mannodermaus for the contribution of Android CI tests, PR#178
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