title: Thread-safe in-memory cache
body: <p>I need a simple thread-safe in-memory cache in my Scala application.</p>
  
  <p>I need a data structure which support this operation from <code>scala.collection.mutable.MapLike</code>:</p>
  
  <pre><code>def getOrElseUpdate(key: A, op: =&gt; B)
  </code></pre>
  
  <p>and I want this operation to be atomic. Is this operation atomic in <code>scala.collection.concurrent.TrieMap</code>? Or should I use some other data structure?</p>
  
  <p>I use Scala 2.10, but will probably upgrade to 2.11 soon.</p>
  
  <p>I don't want to use <code>scala.collection.mutable.SynchronizedMap</code>, since it is deprecated in Scala 2.11.</p>