Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.1B1
-
None
Description
Here is a problematic piece of code:
public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
String key = metadata.getCacheKey();
if (key == null)
Ehcache cache = null;
Element result = null;
String[] groupNames = metadata.getCacheGroups();
if (groupNames != null && groupNames.length > 0) {
// SHOULD WE USE 'addCacheIfAbsent' here, as we already have a factory to populate object???
cache = cacheManager.getCache(groupNames[0]);
if (cache == null)
....
Sure enough there is a workaround of declaring all cache groups as "caches" within ehcache.xml, so this issue may be about usability and consistency after all ('put' for instance uses 'addCacheIfAbsent', but not 'get' with factory).
Also maybe we can refactor calls to 'get' and 'put' within this method to avoid multiple cache lookups, when we already have a cache instance in place.