title: Google Guava's CacheLoader loadAll() method Implementation Issues
body: <p>I am interested in knowing what is the effective way of loadAll method implementation  introduced in google guava 11.0 library. </p>
  
  <p>Here is the following code that describes load all method implementation extended<br>
  as per the example from CachesExplained </p>
  
  <pre><code>LoadingCache&lt;Key, Graph&gt; graphs = CacheBuilder.newBuilder().maximumSize(1000)
  .refreshAfterWrite(1, TimeUnit.MINUTES)
  .build(
     new CacheLoader&lt;Key, Graph&gt;() {
       public Graph load(Key key) { // no checked exception
         return getGraphFromDatabase(key);
       }
  
       public Map&lt;Key, Graph&gt; loadAll(Iterable&lt;? extends K&gt; keys) {
           return getAllGraphsFromDatabase(keys);
       }
     }
  );
  
  private Map&lt;Key, Graph&gt; getAllGraphsFromDatabase(Iterable&lt;? extends key&gt; keys)
  {
    lListOfGraph = //resultset got from DB Call
    for (lCount = 0; lCount &lt; lListOfGraph.size(); lCount++)
    {
       lGraph = (Graph)lListOfGraph.get(lCount).get(0);
       graphs.asMap().put((key , lGraph);
    }
    return (Map&lt;key, Graph&gt;) graphs;
  }
  </code></pre>
  
  <p>Here return type that is Map throws error java.lang.ClassCastException:com.google.common.cache.LocalCache$LocalLoadingCache cannot be cast to java.util.Map (Knowing the fact that Loading Cache object can not be of type Map)</p>
  
  <p>If this is not the correct way of implementation of using LoadingCache then
  How is the data injected in LoadingCache's Component so that it can be used as Cache.  </p>