Adding Items

Once you have a valid cache handle, you can do the "Add" operations. The Add operation has many overloads and the basic overload takes two parameters, "key" as string and "value" as object. The value must be a Java serializable object otherwise NCache will throw a serialization exception.

Using Add Method

Here is how you can add items to the cache. An "Add" method will add item to the cache only if that item does not already exist in the cache. Otherwise, it will throw an exception.

Include the following import statement in your project:

importcom.alachisoft.ncache.web.caching.*;

Create a new Class named 'Customer' in your already created Test Application.