I would not use a card, it needs a lot of memory. Especially in your case. Store the values ββin one data array and store the keys in a sorted array of indices. In a sorted array, you use binSearch to find the key position in the [] data.
The hard part will be to create an array without running out of memory.
you do not need to consider concurreny because you are only reading data
In the future, try to avoid using a string key. try converting them to long ones.
advantage of this solution: the search time does not exceed log n. even in worst cases when keys create hashcode problems
source share