I am trying to understand why my reload function is not called after the refreshAfterWrite duration so, I implemented this simple test:
`
import cats.implicits.catsSyntaxOptionId
import com.github.blemale.scaffeine.{AsyncLoadingCache, Scaffeine}
import com.typesafe.scalalogging.LazyLogging
import org.mockito.ArgumentMatchersSugar
import org.scalatest.concurrent.ScalaFutures.whenReady
import org.scalatest.matchers.must.Matchers
import org.scalatest.wordspec.AnyWordSpecLike
Hi,
I am trying to understand why my reload function is not called after the refreshAfterWrite duration so, I implemented this simple test: ` import cats.implicits.catsSyntaxOptionId import com.github.blemale.scaffeine.{AsyncLoadingCache, Scaffeine} import com.typesafe.scalalogging.LazyLogging import org.mockito.ArgumentMatchersSugar import org.scalatest.concurrent.ScalaFutures.whenReady import org.scalatest.matchers.must.Matchers import org.scalatest.wordspec.AnyWordSpecLike
import java.util.concurrent.TimeUnit import scala.concurrent.Future import scala.concurrent.duration.FiniteDuration
class ScalaCaffeineSpec extends AnyWordSpecLike with Matchers with ArgumentMatchersSugar with LazyLogging {
val refreshAfter: FiniteDuration = FiniteDuration(100, TimeUnit.MILLISECONDS)
val asyncCache: AsyncLoadingCache[Int, Int] = Scaffeine() .maximumSize(1) .refreshAfterWrite(refreshAfter) .expireAfterAccess(FiniteDuration(1, TimeUnit.HOURS)) .recordStats() .buildAsyncFuture( loader = (: Int) => Future.successful(1), reloadLoader = ((: Int, _: Int) => reload).some )
private def reload: Future[Int] = Future.successful(2)
"Scala AsyncLoadingCache cache" must { "load" in { whenReady(asyncCache.get(1))(_ mustBe 1) }
}
} `
the reload fails, any idea ?