views:

66

answers:

2

I just started working with Oracle's Coherence cache and I noticed this: If I put in a ConcurrentHashMap object in the cache, when I retreive it, I could see that it is converted to a normal HashMap.

Anything I can do to avoid this internal conversion?

A: 

I figured it out. I removed the <serializer> entries from the configuration xml. Now it works fine. But, I think cross platform support may suffer (e.g. .net).

sreenisatish
+1  A: 

An equivalent for Java's ConcurrentHashMap (or for that matter other collection types) may not exist in another platform, so the Coherence cache just persists the list of key-value pairs in the map. This is why you get a HashMap back.

A better way is to create your own map class based on ConcurrentHashMap (in the Java version) and your own serializer. Using the PofWriter.writeMap and PofReader.readMap methods you can arrange to get a ConcurrentHashMap back. If you then need a .Net version you can make your map class use whatever map works best in .Net, and provide an appropriate custom serializer.

David Cooke