You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2015/05/06 08:58:44 UTC

svn commit: r1677937 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java

Author: thomasm
Date: Wed May  6 06:58:44 2015
New Revision: 1677937

URL: http://svn.apache.org/r1677937
Log:
OAK-2834 LIRS cache: allow to disable it when using the persistent cache

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java?rev=1677937&r1=1677936&r2=1677937&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java Wed May  6 06:58:44 2015
@@ -82,10 +82,14 @@ public class DocumentMK {
             "oak.documentMK.manyChildren", 50);
 
     /**
-     * Enable the LIRS cache.
+     * Enable or disable the LIRS cache (null to use the default setting for this configuration).
      */
-    static final boolean LIRS_CACHE = Boolean.parseBoolean(
-            System.getProperty("oak.documentMK.lirsCache", "false"));
+    static final Boolean LIRS_CACHE;
+    
+    static {
+        String s = System.getProperty("oak.documentMK.lirsCache");
+        LIRS_CACHE = s == null ? null : Boolean.parseBoolean(s);
+    }
 
     /**
      * Enable fast diff operations.
@@ -891,7 +895,14 @@ public class DocumentMK {
         
         private <K extends CacheValue, V extends CacheValue> Cache<K, V> buildCache(
                 long maxWeight) {
-            if (LIRS_CACHE || persistentCacheURI != null) {
+            // by default, use the LIRS cache when using the persistent cache,
+            // but don't use it otherwise
+            boolean useLirs = persistentCacheURI != null;
+            // allow to override this by using the system property
+            if (LIRS_CACHE != null) {
+                useLirs = LIRS_CACHE;
+            }
+            if (useLirs) {
                 return CacheLIRS.newBuilder().
                         weigher(weigher).
                         averageWeight(2000).