title: cache2k, read through and blocking
body: <p>I have used <strong>cache2k</strong> with <em>read through</em> in a web application to load blog posts <em>on demand</em>.  However, I am concerned about <strong>blocking</strong> for the <em>read through</em> feature.  For example, if multiple threads (requests) ask the cache for the same <em>key</em>, is it possible for the <em>read through</em> method to be called multiple times to <em>load</em> the same key/value into the cache?</p>
  
  <p>I get the <em>impression</em> from the documentation that the <em>read through</em> feature does <strong>block</strong> concurrent requests for the same key until the <em>load</em> has completed, but may I have mis-read the documentation. I just want to check that this is the behaviour.</p>
  
  <p>The method which initializes the cache looks like this:</p>
  
  <pre><code>private void initializeURItoPostCache()
  {
      final CacheLoader&lt;String, PostImpl&gt; postFileLoader = new CacheLoader&lt;String, PostImpl&gt;(){
          @Override public PostImpl load(String uri)
          {
              // Fetch the data and create the post object
              final PostImpl post = new PostImpl();
              //.. code omitted
              return post;
          }
      };
  
      // Initialize the cache with a read-through loader
      this.cacheUriToPost = new Cache2kBuilder&lt;String, PostImpl&gt;(){}
      .name("cacheBlogPosts")
      .eternal(true)
      .loader(postFileLoader)
      .build();
  }
  </code></pre>
  
  <p>The following method is used to request a post from the cache:</p>
  
  <pre><code>public Post getPostByURI(final String uri)
  {
      // Check with the index service to ensure the URI is known (valid to the application)
      if(this.indexService.isValidPostURI(uri))
      {
          // We have a post associated with the given URI, so
          // request it from the cache
          return this.cacheUriToPost.get(uri);
      }
      return EMPTY_POST;
  }
  </code></pre>
  
  <p>Many thanks in advance, and a happy and prosperous New Year to all.</p>