title: How to make LoadingCache to call load() in a non blocking fashion()?
body: <p>I'm using Google's guava library to create my cache. I'm going with LoadingCache interface for it. Below is the code snippet,</p>
  
  <pre><code>public class BlockedURLs {
  private static final long MAX_SIZE = 1000;
  private static final long CACHE_DURATION = 2;
  
  private static LoadingCache&lt;String, ArrayList&lt;String&gt; &gt; lruBlockedURLCache;
  
  BlockedURLs() {
      lruBlockedURLCache = CacheBuilder
              .newBuilder()
  
              .maximumSize(MAX_SIZE)
  
              .expireAfterWrite(CACHE_DURATION, TimeUnit.HOURS)
  
              .build(new CacheLoader&lt;String, ArrayList&lt;String&gt;&gt;() {
                  @Override
                  public ArrayList&lt;String&gt; load(String s) throws Exception {
                      return BlockedURLLoader.fetchBlockedURLListFromRedis(s);
                  }
  
              });
  }
  
  public static ArrayList&lt;String&gt; getBlockedURLList(String domain) {
      return lruBlockedURLCache.getUnchecked(domain);
  }
  }
  </code></pre>
  
  <p>As I understand it, if I call getBlockedURLList for a domain for which the List is not cached it will load the list first and then return the result. But, that's not the behaviour I want.</p>
  
  <p>If the key isn't present in cache, I expect cache to call it's load function but I want to do it asynchronously. So, if the key wasn't present, I'll say I can work with no key in cache this time and move on, but I want the key to be present next time I try to fetch it. Essentially, I want to call load() in non-blocking fashion. That is cache.get() should not wait till the result is fetched from load() first.</p>