A very primitive effectful LRU cache for Cats Effect with support for Scala.js and Scala Native without external dependencies.
// JVM
mvn"digital.junkie::murcache:0.0.1"
// Scala.js / Scala Native
mvn"digital.junkie::murcache::0.0.1"// JVM
"digital.junkie" %% "murcache" % "0.0.1"
// Scala.js / Scala Native
"digital.junkie" %%% "murcache" % "0.0.1"import cats.effect.IO
import digital.junkie.murcache.MurCache
val program = for {
cache <- MurCache.simple[IO, String, Int](
default = key => IO.pure(key.length),
maxSize = 2
)
first <- cache.get("hello")
second <- cache.get("hello")
_ <- cache.put("world", 99)
third <- cache.get("world")
_ <- cache.invalidate("hello")
} yield (first, second, third)