Now insert the following code in the 'Main' of the project.
Cache _cache1 = NCache.initializeCache("myCache");
Cache _cache2 = NCache.initializeCache("myReplicatedCache");
// Perform any of the operations provided by NCache on any of the cache initialized
_cache1.clear();
_cache2.clear();
Customer customer = new Customer();
customer.name = "David";
customer.customerID = 1001;
customer.setCity("London");
customer.setContactNumber("+44-xxx-xxxx-xxxx");
customer.setOrderInProcess(true);
Customer customer1 = new Customer();
customer1.name = "Alex";
customer1.customerID = 1002;
customer1.setCity("Chicago");
customer1.setContactNumber("+44-xxx-xxxx-xxxx");
customer1.setOrderInProcess(false);
// Add Item to Cache
NCache.getCaches().getCache("myCache").add("Customer:David:1001", customer);
NCache.getCaches().getCache("myReplicatedCache").add("Customer:Alex:1002", customer1);
// Get Items from Cache
Object object_Customer = NCache.getCaches().getCache("myCache").get("Customer:David:1001");
Object object_Customer1 = NCache.getCaches().getCache("myReplicatedCache").add("Customer:Alex:1002");
Customer customerInformation = (Customer)object_Customer;
System.out.println("Customer ID: " + customerInformation.customerID);
System.out.println("Name: " + customerInformation.name);
System.out.println("City: " + customerInformation.getCity());
System.out.println("Contact Number: " + customerInformation.getContactNumber());
System.out.println("Order placed: " + customerInformation.isOrderInProcess());
System.out.println();
customerInformation = (Customer)object_Customer1;
System.out.println("Customer ID: " + customerInformation.customerID);
System.out.println("Name: " + customerInformation.name);
System.out.println("City: " + customerInformation.getCity());
System.out.println("Contact Number: " + customerInformation.getContactNumber());
System.out.println("Order placed: " + customerInformation.isOrderInProcess());