Friday, December 24, 2010

KeySet & ehcache

KeySet is a view of keys contained in the Map.

In ehcache, I store <id, Map>.

Map oldAuthApInfos = cache.get(id);
SetoldBssids = oldAuthApInfos.keySet();

This would result in map entries getting removed from cache. By default, ehcache uses memoryStore and basically is a map. The operation on the returned map have direct effect on cache value itself. I used to think the returned map of cache.get() is a serialized copy of the cache value.


Steve Harris said...

You can get the serialized behavior you were expecting by using copyOnRead/copyOnWrite in the config

Ginger said...

Thank you. It's good to know.