ofbiz-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Manes (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OFBIZ-6747) Replace ConcurrentLinkedHashMap by Caffeine
Date Sat, 09 Jun 2018 18:30:00 GMT

    [ https://issues.apache.org/jira/browse/OFBIZ-6747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16507108#comment-16507108

Ben Manes commented on OFBIZ-6747:

The two libraries do share a compatible interface via {{ConcurrentMap}}. That is the interface
for {{ConcurrentLinkedHashMap}} and provided by Caffeine's {{Cache.asMap()}} view. You are
welcome to abstract out caching as you see fit, as neither are invasive (e.g. no singleton
{{CacheManager}} or configuration files - those are for applications to introduce and manage).

{{ConcurrentLinkedHashMap}} was written for Java 5, so it does not provide atomic versions
of the new default methods such as {{computeIfAbsent}}. I believe that the copy embedded by
Groovy did add this, if you want to follow their example. The library is tiny, so many brought
it under their own umbrella to avoid external dependencies (e.g. another example is SQL Server's
JDBC driver).

Unfortunately most other caching libraries do no support {{ConcurrentMap}}, so bridging them
might be difficult. You may instead prefer to have a custom {{Cache}} interface with only
the methods your project finds useful to minimize the effort. Another option is {{JSR107 JCache}} but
be warned that it is riddled with problems, highly flawed, and results in a very frustrating
developer experience. While the JSR was approved, it was rejected by JavaEE (both EE7 and
EE8) and not widely adopted by consuming frameworks / applications.

> Replace ConcurrentLinkedHashMap by Caffeine
> -------------------------------------------
>                 Key: OFBIZ-6747
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6747
>             Project: OFBiz
>          Issue Type: Task
>            Reporter: Ben Manes
>            Assignee: Jacques Le Roux
>            Priority: Minor
> Similar to OFBIZ-3779, please consider upgrading the library used by [UtilCache|https://github.com/apache/ofbiz/blob/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java]
(v1.2). The current version is 1.4.2 and is the last major release planned.
> The preferable alternative would be to upgrade to [Caffeine|https://github.com/ben-manes/caffeine].
This is a Java 8 rewrite based on what I've learned since developing CLHM and Guava's cache.
As expected it provides [superior performance|https://github.com/ben-manes/caffeine/wiki/Benchmarks].
It also provides a [near optimal|https://github.com/ben-manes/caffeine/wiki/Efficiency] eviction

This message was sent by Atlassian JIRA

View raw message