Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.

Cache Collections

Cache based Collections

Cache decorator decorates a java.util.Collection, java.util.Set, java.util.List, java.util.Map, ... and improve the performance of them by reducing the search-overhead for often used elements. Cache collections should be used on the client site to improve the performance for element-management on the server-site.


Cache collection can be easily created by using the static of() method.

//decorate the collection
c = CacheCollection_1x0.of(cacheSize, c);


CacheList can be created in the same manner as CacheCollection.

//decorate the collection
list = CacheList_1x0.of(cacheSize, list);


There is no need to decorate HashSet or TreeSet, because these sets are very fast if any elements must be found. But there are also some Set implementation which uses the LinkedList, such sets should be decorated, see code bellow:

//decorate the collection
set = CacheSet_1x0.of(cacheSize, set);


The benchmark is presented in this example. The performance which you can expect from using the cache-decorator for the collection with 100,000 elements is about 30% and for a collection with 1,000,000 about 50%. Use cache-decorators only if in your collection few elements are used very often, else the cache doesn't have any sense and produce additional overhead!

Cache based Collections examples