title: Designing a Guava LoadingCache with variable entry expiry
body: <p>I am using Guava's LoadingCache into my project to handle thread-{safe,friendly} cache loading and it works wonderfully well. However, there is a limitation.</p>
  
  <p>The current code defining the cache looks like this:</p>
  
  <pre><code>cache = CacheBuilder.newBuilder().maximumSize(100L).build(new CacheLoader&lt;K, V&gt;()
  {
      // load() method implemented here
  }
  </code></pre>
  
  <p>I don't specify an expiry time.</p>
  
  <p>The problem is that according to the values of the key, some associated values may expire and others may not. And <code>CacheLoader</code> does not account for this, if you specify an expiry time, it is for each and every entry.</p>
  
  <p>How would you tackle this problem?</p>