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