title: using guava cache without a load function
body: <p>My java app has a cache, and I'd like to swap out the current cache implementation and replace it with the guava cache.</p>
  
  <p>Unfortunately, my app's cache usage doesn't seem to match the way that guava's caches seem to work.  All I want is to be able to create an empty cache, read an item from the cache using a "get" method, and store an item in the cache with a "put" method.  I do NOT want the "get" call to be trying to add an item to the cache.</p>
  
  <p>It seems that the LoadingCache class has the get and put methods that I need.  But I'm having trouble figuring out how to create the cache without providing a "load" function.</p>
  
  <p>My first attempt was this:</p>
  
  <pre><code>LoadingCache&lt;String, String&gt; CACHE = CacheBuilder.newBuilder().build();
  </code></pre>
  
  <p>But that causes this compiler error: incompatible types; no instance(s) of type variable(s) K1,V1 exist so that Cache conforms to LoadingCache</p>
  
  <p>Apparently I have to pass in a CacheLoader that has a "load" method.</p>
  
  <p>(I guess I could create a CacheLoader that has a "load" method that just throws an Exception, but that seems kind of weird and inefficient.  Is that the right thing to do?)</p>