I am trying to implement a simple usecase using Guava caching but facing some issues as shown below:
case class Person(x:Int, y:String)
val db = Map(1 -> Person(1,"A"), 2 -> Person(2,"B"), 3 -> Person(3,"C"))
val loader:CacheLoader[Int,Person] = new CacheLoader[Int,Person](){
def load(key: Int): Person = {
db(key)
}
}
lazy val someData = CacheBuilder.newBuilder().expireAfterWrite(60, MINUTES).maximumSize(10).build(loader)
someData.get(3)
The error I am getting is related to types which I am not able figure out
scala> someData.get(3)
<console>:24: error: type mismatch;
found : Int(3)
required: Int
someData.get(3)
Can someone advice on what can be the issue.