Conversation
SIRI-1175
SIRI-1175
SIRI-1175
…as the cache actually contains cache entries that have additional information. SIRI-1175
…in order to safe unchecked casts. SIRI-1175
There was a problem hiding this comment.
Pull request overview
This PR migrates the caching implementation from Guava Cache to Caffeine, a more performant drop-in replacement.
Changes:
- Replaced Guava Cache imports and API calls with Caffeine equivalents throughout the cache implementation
- Updated return type from
DatetoInstantforgetLastEvictionRun()method - Added comprehensive test coverage for the removal listener functionality
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pom.xml | Added Caffeine 3.2.3 dependency as replacement for Guava Cache |
| src/main/java/sirius/kernel/cache/Cache.java | Updated interface to use Instant instead of Date for eviction timestamp |
| src/main/java/sirius/kernel/cache/ManagedCache.java | Replaced Guava Cache with Caffeine, including API changes for cache building, removal listeners, and size estimation |
| src/test/kotlin/sirius/kernel/cache/ManagedCacheTest.kt | Corrected class documentation and added test for removal listener invocation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cache.put("key1", "value1") | ||
| cache.remove("key1") | ||
|
|
||
| Wait.millis(1001) |
There was a problem hiding this comment.
The hardcoded 1001ms wait is excessive and will slow down test execution. Since removal listeners in Caffeine are invoked synchronously during removal operations, this wait should not be necessary. Consider removing this wait or reducing it significantly if there's a specific asynchronous behavior being tested.
There was a problem hiding this comment.
Reicht hier ein @NightlyTest? Oder bekommt man das Wait sogar weg?
There was a problem hiding this comment.
Ich habe die Wartezeit reduziert auf eine Zehntelsekunde. Ich würde den Test schon ganz gerne belassen.
SIRI-1175
Description
Replaces Guava Caches with Caffeine.
Caution
After upgrading, the major breaking change is that
cache.getLastEvictionRun()now returns anInstantrather than aDate. AsDateshould not be used anymore, the best solution is to upgrade the surrounding code to use the Java Time libraries as well. However, if that is not feasible, conversion to aDateas before can be done viaDate.from(cache.getLastEvictionRun()).The new caching library should not have changed the behaviour of the cache. Still, increased attention should be given to performance of code known to use caching.
Additional Notes
Checklist