I am very excited about this new series I am publishing today. It’s all about caching, a very useful portion of your architecture that should be seriously taken into consideration, especially if you are designing a web application.
Actually, I used NCache with NHibernate and I can only say that it is a very good and valuable product. Of course most of you may believe that I got a free license so this is the reason of my review. Actually I am reviewing this product because I found it pretty good and that’s why the review came up with a short series of articles.
I will show you the following features of NCache:
- NCache architecture
- Simple caching of objects
- Caching of complex graph
- Control the lifetime of a cache
From NCache documentation:
NCache is a clustered caching solution that makes sharing and managing data in a cluster as simple as on a single server. It accomplishes this by coordinating updates to the data using cluster-wide concurrency control and replicating and distributing data modifications across the cluster using the highest performing clustered protocol available. The primary purpose of NCache is to help improve performance of .NET applications that would otherwise make expensive trips to database systems, web services, mainframes, or other systems across the network.
Below is a very simplified diagram of NCache architecture (please forgive me for the simplicity of this architecture design):
So, how does it work?
The explanation is pretty simple but in the same time is represented by a complex architecture. You can have two different type of Cache, a local cache or a remote cache. The first one will work because the client has a cache server installed locally, the second one will work with the client accessing the remote cache server from the network.
Of course you can easily swap from a local configuration to a remote configuration without even need to restart or rebuild your application, plus you can easily add or remove cache clusters to your architecture using an “hot swap” technology that doesn’t require any reboot or re-configuration.
Let’s try to get practical and let’s write some code, otherwise this blog post will get really boring!
In order to use NCache you have to go to this web address and download a 60 days trial version: http://www.alachisoft.com/download.html. There are three major versions: NCache for .NET (x86 and x64) in two flavors, Enterprise and Professional, NCache for Java (x86 and x64) and NCache express (a free version with a limited amount of features). In this demo I will use the full version for .NET in x64 bit Professional. The setup for the professional edition is about ~30 Mb and it’s pretty quick to install.
The Wizard will propose you three different types of installation, like the screenshot below:
In my case I need a developer license because I will run everything from my machine and I need also to have access to NCache API. The cache server installation is used to install a new cluster while the Remote Client installation is used to install the client connection components used by your applications to access the remote cache servers.
As soon as NCache is installed you will get a new icon in your start menu (in my case is a tile because I have Windows 8):
In the next posts I will show you how to configure your first cache and how to write a WPF application that will work against this cache.