Hi all,
I am making progress on a Java 11 release of Caffeine, which is currently Java 8 based. Since this is a major version bump we can make some incompatible changes if we restrict those to small ones with a relatively low impact. Are there any aspects of Guava's Cache / Caffeine that you would reconsider?
The current list of changes are,
1. Replace Unsafe with VarHandles
2. Use the Platform Logger api instead of j.u.Logger
3. Linearizable cache refresh if intermediate removal (Guava inserts a potentially stale value)
4. LoadingCache#refresh now returns the future
5. If a refresh is in-flight, an explicit refresh should return that future rather than trigger another reload (now matches Guava)
6. Minor api tidiness
These changes are nearing completion and reside in the v3 branch.
A change that I am considering is to introduce Caffeine#evicttionListener(RemovalListener), which performs the callback atomically when the entry is being evicted. This would resolve Guava #1481 and #1991, where the removal listener notification outside of the cache's lock was problematic. Caffeine currently offers this using its CacheWriter, but it was a mistake to borrow that concept from other libraries. To serve this purpose it is verbose, confusing, and is incompatible with weak keys and asynchronous caches. The interception of writes is not very useful, thanks to Map#compute methods which should be preferred. Since it is not commonly used, do you think we should softly deprecate and keep it or use the major version bump to allow removing the class entirely? If we did the latter, then an intermediate 2.x release would deprecate and add the feature to help smooth the transition.
Please let me know if you have suggestions for further refinements.
Thanks and happy new year,
Ben