JCS or java.util.Map, which is efficient in terms of time?

181 Views Asked by At

We are writing a test framework and we want to maintain a data structure for storing objects at suite level, objects vary from int to slf4j Logger. I am not clear as which data structure to use, which is more effective.

1

There are 1 best solutions below

0
On

A HashMap is simpler and faster, is not thread safe. (that is why it is fastest)

Other Caching systems are more sophisticated which means there will be a small overhead. Also will be thread safe.

JCS support LRU and MRU, The LRU Memory Cache is an extremely fast, highly configurable memory cache. It uses a Least Recently Used algorithm to manage the number of items that can be stored in memory. The LRU Memory Cache uses its own LRU Map implementation that is significantly faster than both the commons LRUMap implementation and the LinkedHashMap that is provided with JDK1.4 up.

a good read here