Alachisoft NCache 4.1 - Online Documentation

Using Compact Types

NOTE: This feature is not available in NCache Express and Professional edition.
NCache has enhanced this feature to support dynamic compact serialization which allows users to use this feature without any code change. In earlier versions users had to implement the interfaces which are not required anymore in this version. To use Compact Serializable types with NCache Configure Cache with NCache Manager and then register your compact serializable types with NCache.
Registering Compact Serializable Types
You can register types one by one through 'Add Types' button. Perform the following steps to register your types with configured cache:
  • Stop the cache if it is running.
  • Click on the 'Compact Serialization' tab which will open up the following screen.
  • Click 'Add Types' button. A 'Select Compact Classes' dialog will appear.
  • Browse for the assembly file that contains the compact types by clicking the 'Browse' button as shown in the figure.
  • Select the classes you want to register with the cache from the loaded classes list.
  • Press 'Add Class' button to add the classes in the selected classes list.
  • Click 'Ok' button.
  • Newly added types will start appearing in the list box under the 'Compact Serialization' tab having Compact Type and Platform information.
  • 'Remove' button will delete the selected type from the registered types list.
  • This shows all the added types. Now arguments can be added with generic types by selecting specific type and then clicking on 'Add <T>' button.
Registering Generic Compact Types Through Generic Type Handler
This is the other way for registering generic compact types through "Generic Type Handler". With Generic Type Handler user can add all the Generic types at once by implementing our interface. This saves time and effort. Here is a sample code for this.
  public class CustomGenericType<T,K,V>
          public class SetGenerics: IGenericTypeProvider
              Type[] types = new Type[6];
              #region IGenericTypeProvider Members
              Type[] IGenericTypeProvider.GetGenericTypes()
                  types[0]=typeof(Dictionary<string, Customer>);
                  types[2]=typeof(CustomGenericType<Employee, Product, Customer>);
                  types[3]=typeof(CustomGenericType<Employee, Product, int>);
                  types[4]=typeof(CustomGenericType<Employee, string, byte>);
                  types[5]=typeof(CustomGenericType<string, Customer, bool>);
                  return types;
  For registering types follow these steps.
  • Click 'Generic Type Handler' button. A 'Select Compact Classes' dialog box will appear.
  • Browse for the assembly file that implements this interface and contains compact types by clicking the 'Browse' button as shown in the figure.
  • Click 'Ok' button. All the added types will be listed as shown blow.

Copyright © 2005-2012 Alachisoft. All rights reserved.