How to cache results in scala?

前端 未结 5 583
孤街浪徒
孤街浪徒 2020-12-31 01:51

This page has a description of Map\'s getOrElseUpdate usage method:

object WithCache{
  val cacheFun1 = collection.mutable.Map[Int, Int]()
  def         


        
5条回答
  •  长发绾君心
    2020-12-31 02:44

    See the Memo pattern and the Scalaz implementation of said paper.

    Also check out a STM implementation such as Akka.

    Not that this is only local caching so you might want to lookinto a distributed cache or STM such as CCSTM, Terracotta or Hazelcast

提交回复
热议问题