Use Coherence caches to cache value objects. These objects may represent data from any source, either internal (such as session data, transient data, and so on) or external (such as a database, mainframe, and so on).
Objects placed in the cache must be serializable. Because serialization is often the most expensive part of clustered data management, Coherence provides the following options for serializing/deserializing data:
com.tangosol.io.pof.PofSerializer – The Portable Object Format (also referred to as POF) is a language agnostic binary format. POF was designed to be incredibly efficient in both space and time and has become the recommended serialization option in Coherence. See Chapter 19, "Using Portable Object Format."
java.io.Serializable – The simplest, but slowest option.
java.io.Externalizable – This requires developers to implement serialization manually, but can provide significant performance benefits. Compared to
java.io.Serializable, this can cut serialized data size by a factor of two or more (especially helpful with Distributed caches, as they generally cache data in serialized form). Most importantly, CPU usage is dramatically reduced.
com.tangosol.io.ExternalizableLite – This is very similar to
java.io.Externalizable, but offers better performance and less memory usage by using a more efficient I/O stream implementation.
Note:Remember, when serializing an object, Java serialization automatically crawls every visible object (by using object references, including collections like
List). As a result, cached objects should not refer to their parent objects directly (holding onto an identifying value like an integer is OK).
Objects that implement their own serialization routines are not affected.