title: Map based cache with expiration and soft values
body: <p>I'm looking to cache information in a Map so I don't have to keep, for example, hitting a DB. In Java I'd use Google collection's excellent <a href="https://github.com/google/guava/commits/master/guava/src/com/google/common/collect/MapMaker.java" rel="nofollow noreferrer">MapMaker</a> and set an expiry, to keep the cache as fresh as necessary, and softValues, to keep the memory usage down. Then I'd have a function that computes the value for a key that currently isn't cached.</p>
  
  <pre><code>MapMaker().softValues
            .expireAfterWrite(10, TimeUnit.MINUTES)
            .makeComputingMap(Function(...));
  </code></pre>
  
  <p>What's the best way to do this in Scala?</p>