You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/10/22 21:14:57 UTC

[2/2] isis git commit: ISIS-1195: adding comments only to QueryResultsCache.

ISIS-1195: adding comments only to QueryResultsCache.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/9a632804
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/9a632804
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/9a632804

Branch: refs/heads/master
Commit: 9a632804fcd07c79bb49f758ce5f97efeb2a88bd
Parents: d4c5dbc
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Oct 22 20:14:45 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Oct 22 20:14:45 2015 +0100

----------------------------------------------------------------------
 .../services/queryresultscache/QueryResultsCache.java    | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/9a632804/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCache.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCache.java b/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCache.java
index ed2330d..d6cd6af 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCache.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCache.java
@@ -142,9 +142,18 @@ public class QueryResultsCache {
             if(cacheValue != null) { 
                 return (T) cacheValue.getResult();
             }
-            // cache miss, so get the result, and cache
+
+            // cache miss, so get the result...
             T result = callable.call();
+
+            // ... and cache
+            //
+            // (it is possible that the callable just invoked might also have updated the cache, eg if there was
+            // some sort of recursion.  However, Map#put(...) is idempotent, so valid to call more than once.
+            //
+            // note: there's no need for thread-safety synchronization... remember that QueryResultsCache is @RequestScoped
             put(cacheKey, result);
+
             return result;
         } catch (Exception e) {
             throw new RuntimeException(e);