0

I need to store some values category wise in key-value pair in cache,for eg: category1 = {(k1,v1),(k2,v2)} category1 = {(k3,v3),(k4,v4)}

which can be accessed concurrently. I am looking like partitioning the concurrent HashMap, but dont know exactly what data structure to use. Any idea?, Thanks

user3363969
  • 233
  • 1
  • 4
  • 15

1 Answers1

0

This may be useful for you,

ArrayList<Map> categoryWrapperList = new ArrayList<Map>();
Map category1 = new HashMap<Integer, Integer>();
category1.put(1, 2);
category1.put(2, 3);
Map category2 = new HashMap<Integer, Integer>();
category2.put(11, 2);
category2.put(21, 3);
categoryWrapperList.add(category1);
categoryWrapperList.add(category2);

Here, Arraylist will store all the categories, and you can put any value in the category. you, obviously can see more about ArrayList for time consumption by arraylist in various operations(like get, search etc).

Gaurav Gupta
  • 4,586
  • 4
  • 39
  • 72