I am looking for suggestions to a fast Map
with Long
keys. It will have a lot of read accesses and rather small write/update accesses. Performance should thus focus on read (get
) access. It must be thread-safe. Some ideas:
- regular
collection.Map[Long, _]
has to box keys - bare bones
collection.mutable
would have to wrapsynchronized
all the time, penalising read access - bare bones
collection.immutable
could have unsynchronized read access if stored in a@volatile
var
. Update could synchronize. - perhaps
TMap
from Scala-STM? But then aRef[Map[Long, _]]
probably is as good because concurrent reads should be allowed in STM
To me No. 3 sound best?