NCache 4.4 - Online Documentation

Overview

 
NCache stores application data in serialized form. Data is serialized on cache client before adding it to cache. Therefore data to be added in cache must also be marked as serializable. It supports native binary serialization for both JvCache client and NCache client and it also has its own serialization framework called compact serialization which is fast and compact than native serialization. In native serialization of .NET, all data of an object along with the entire type information is serialized. In this way, size of the object increases, whereas in compact serialization, the entire type information does not travel on the network so the object size which travels on network is reduced. As the object size decreases, network trips become faster and eventually the cost decreases while increasing the overall application performance.
 
Compact serialization is also binary serialization and has the following benefits:
 
Compact Data Size
 
In NCache, binary data size of the serialized object is compact. In certain scenarios data size may be 10 times less than that of native serialization. Smaller serialized objects take less time to travel on the network which results in a higher through put. This also helps in reducing memory consumption on cache’s server. In this manner NCache achieves better performance while reducing time and cost. Small object size and fast network traffic increases the application performance.
 
Fast
 
Compact serialization is faster than native serialization as it does not rely as much on reflection as native serialization does. Native serialization uses reflection for attribute information, this reflection is avoided in NCache’s compact serialization, type information for compact types are loaded only once when cache is initialized, which reduces the overhead faced using native serialization. Benchmarks have shown that in certain use cases, it is 5~10 times faster than native serialization.
 
No Code Change
 
There is no code change required to make a class compact serializable. The only step required is to configure your classes through management tools. (NCache Manager or command line tools).
 
NCache 4.3 and later versions allow selective serialization. It allows data members of a class to be mark as non-serializable. Please see administrator’s guide for more details. The excluded attributes’ values will not be serialized. The excluded attribute of any cached object will either be null or will have a default value if assigned. This feature is useful in a scenario where for certain attributes, there is no need for caching, e.g., connection object for database. By this selective serialization the process becomes even more efficient and more compact. For using Compact Serialization, a default public constructor (parameter less) in a compact serializable type must be provided and that type must be registered with NCache Manager.
 
The interface ICompactSerializable can be implemented which gives a more fine grained control over compact serialization. Through this interface, which data members are to be serialized and which are to be excluded can be controlled.
 
Support for the compact serialization of Generic Types is also available in NCache. The list of allowed types can be selected and specified either through NCache Manager, or by implementing a generic type handler.
 
The following points must be considered while using compact serialization.
 
  • A compact serializable class can have data members of other classes which are native serializable, but are not compact serializable.
  • A class which is only native serializable cannot have data member which are only compact serializable.
  • If your class is native serializable and it has data members which are both native and compact serializable, then native serialization will be used while serializing the object of container class.
 
 
If Read/Write-through provider or cache startup loader is configured along with compact serialization, then the assemblies containing compact classes should be deployed along with providers. For example, in a scenario where cache loader is configured, during cache filling, items are fetched from data source. These items are serialized before they are inserted into cache; here for serialization, assembly containing compact classes is required.
 
 
 
 
An object registered in Data Sharing cannot be registered in Compact Serialization at the same time.
 
 
 
 
See Also