Scala disk card
I have a large card that won't fit in memory, and so I want it to be on disk. I have the following options:
- Use a pure Java library like MapDB : This works, but I don't get Scala sugar collections like
getOrElseUpdate
and++=
, andapply
/update
. I could create my own wrapper class aroundMapDB
in Scala, but I really don't want to manually apply all the traitsMap
. - Use something like redis / memcached: I couldn't find a good Scala library that gave me the traits
Map
for redis or memcached. This might be the best performance solution, but it introduces db startup complexity
So, is there any good Scala library that implements the Scala collection sagars for maps and yet it comes back to disk and / or keystore for large maps?
+3
source to share
2 answers
Chronicle Map is worth mentioning : it is basically the same as MapDB (hard drive implementation ConcurrentMap
), but much more efficient than MapDB.
Example:
val cache: mutable.Map[String, java.util.List[String]] = ChronicleMap
.of(classOf[String], classOf[java.util.List])
.averageKey("key")
.averageValue(...)
.valueMarshaller(ListMarshaller.of(
CharSequenceBytesReader.INSTANCE,
CharSequenceBytesWriter.INSTANCE
))
.entries(...)
.createPersistedTo(file)
0
source to share