title: Is Guava Cache's read lock free
body: <p>I am using Guava's Cache and have set <code>concurrencyLevel</code> to <code>1</code> so the maximum capacity is utilized w.r.t. eviction is concerned. Following is my code:</p>
  
  <pre><code>CacheBuilder.newBuilder()
                      .maximumWeight(maxWeight)
                      .concurrencyLevel(1)
                      .expireAfterWrite(expireDuration, TimeUnit.MINUTES)
                      .removalListener(new RemovalListener&lt;K, V&gt;() {
                          @Override
                          public void onRemoval(RemovalNotification&lt;K, V&gt; removalNotification) {
                              log.warn(removalMsg + removalNotification.getKey());
                          }
                      })
                      .weigher(weigher)
                      .build();
  </code></pre>
  
  <p>Documentation of <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilder.html#concurrencyLevel%28int%29" rel="nofollow">concurrencyLevel</a> says this:</p>
  
  <blockquote>
    <p>Guides the allowed concurrency among update operations. Used as a hint
    for internal sizing. The table is internally partitioned to try to
    permit the indicated number of concurrent updates without
    contention...</p>
  </blockquote>
  
  <p>And hence I was assuming that the <code>concurrencyLevel</code> plays a role only for <code>update operations</code> and the <code>READs are Lock Free</code> even with <code>concurrencyLevel(1)</code>.</p>
  
  <p>Is my assumption correct ??</p>
  
  <hr>
  
  <p><strong>EDIT:</strong>
  I looked at the Guava Caching codeand it looks like my assumption that <code>READs are lock free</code> is correct. In case of <code>get(K, Callable)</code> initially it tries to get the value without lock and if the entry for the specified key is either null or has expired only then it goes for a locked Get or Load. Please Correct me if I am wrong here.</p>