[ 
https://issues.apache.org/jira/browse/GROOVY-8410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16286364#comment-16286364
 ] 

Jochen Theodorou commented on GROOVY-8410:
------------------------------------------

I think CommonCache is doing to much. You try to cover with one class the LRU 
case as well as the general map case. This then requires you to use a 
LinkedHashMap for the LRU case, but at the same time you allow for an arbitrary 
map... which will then of course not have the LRU capability. And then I could 
think you tried not to mix in concurrency here as well with 
ConcurrentCommonCache, but ConcurrentCommonCache extends CommonCache, which by 
default will use the not thread safe LinkedHashMap again. I wonder if I would 
back the map by a ConcurrentHashMap...  but all the locking in there is not 
needed at all for this map. And then I really do have to ask why we do not one 
version that depends on ConcurrentHashMap for the concurrent case, one for the 
LRU case (concurrent and not concurrent maybe), and the normal on-threadsafe 
versions we probably do not need. Especially considering the good performance 
of ConcurrentHashMap

> Provide a common cache
> ----------------------
>
>                 Key: GROOVY-8410
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8410
>             Project: Groovy
>          Issue Type: Improvement
>    Affects Versions: 3.0.0-alpha-1, 2.5.0-beta-2, 2.4.13, 2.6.0-alpha-2
>            Reporter: Daniel Sun
>            Assignee: Daniel Sun
>             Fix For: 2.5.0-beta-3, 2.6.0-alpha-3, 3.0.0-alpha-2
>
>
> There are many cache implementation in Groovy, many of them are 
> duplicated(e.g. cache algorithm, the code of implementation...). That is to 
> say, Groovy is lack of a common cache.
> The common cache should:
> 1) has two version: thread-safe and not thread-safe for different senario
> 2) achieve basic cache function(manage keys and values, LRU, etc.)
> 3) can specify the map that the cache is based on(Maybe we need WeakHashMap 
> or other Map instance sometimes)
> Here is the implementation of the common cache:
> https://github.com/apache/groovy/blob/master/src/main/org/codehaus/groovy/runtime/memoize/CommonCache.java
> https://github.com/apache/groovy/blob/master/src/main/org/codehaus/groovy/runtime/memoize/ConcurrentCommonCache.java



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to