I'm working in an ecommerce product. This ecommerce has many online stores on many locations. For each category, it has different id in different store. The problem is now we want to mapping categories between stores of the same kind of product.
We have a json stored in database which contains a country mapping:
[
{
"sg": 4,
"jp": 128,
"ph": 4,
"hk": 4,
"th": null
},
...
]
So this means the category id 4 in Singapore is 128 in the Japan. We are actually using a structure like this to map categories across countries.
I have this interface to achieve this:
public interface CategoryMapper {
int getCategory(String sourceCountry, String destinationCountry, int categoryId);
}
I want to optimize for reading speed. How should I implement to achieve this?
I have 2 options below
- Using java hash map to store as key/value
- Using cache framework and store as key/value
Thanks