5

Scalaz provides Memo for memoization. I hope scala-cats also has a similar solution. In general I have a trait with different methods:

trait t {
  def f1:Int = ???
  def f2(i:Int):Int = ???
  def f3(i:Int, s:String):String = ???
}

If such solution is supported by Casts, can you please give an example, how to:

  1. use it to memoizate all previously defined methods in case sources can be modified?

  2. how to apply it to the external code, to inject memoization to client's invocation, without touching existing services

  3. how to control lifecycle of memoization? In general I need to keep results per transaction. What are strategies to control it? Examples would be also great!

Alexandr
  • 9,213
  • 12
  • 62
  • 102
  • 8
    `Memo` is one of the parts of Scalaz that shows its "big bag of extra Scala stuff" heritage, while Cats is more focused on FP-related abstractions, and doesn't have anything directly equivalent. `Memo` doesn't depend on anything else in Scalaz and is a few dozen lines of code, so if you really want to avoid the Scalaz dependency you could just copy-paste. – Travis Brown May 10 '19 at 13:23

0 Answers0