Surendra Sharma

Surendra Sharma

Search This Blog

Tuesday, June 24, 2014

Quick guide to install and use NCache in .NET application

NCache is a distributed in-memory object cache for mission .NET applications which are hosted on web farm environment.

Here are quick steps to install and use NCache in .NET application.

·         Download and install Ncache express from http://www.alachisoft.com/download.html#ncache

·         Open C:\Program Files\NCache Express\config and change cache.config name="mytestreplicatedcache" in config.ncconf file.

·         In client.ncconf, change cache id ="mytestreplicatedcache".

·         Open Perfmon from Run window and test the Ncache counter for object mytestreplicatedcache.

·         Start cache on all nodes, one for Local Cache & two for Replicated Cache. Startcache.exe is located in “%InstallDir%\NCache Express\bin\tools” folder. Do this once for each cache server:
Startcache  cache-id /s serverName

C:\Program Files\NCache Express\bin\tools > Startcache  mytestreplicatedcache /s SERVERNAME

·         Run “AddTestData” command-line program provided with NCache to add some test data to the cache. It is located in “%InstallDir%\NCache Express\bin\tools” folder. Following command adds 100 items of size 1024 bytes each:

AddTestData  cache-id /c 1000 /s 1024

C:\Program Files\NCache Express\bin\tools > AddTestData  mytestreplicatedcache /c 1000 /s 1024

·         Check Green marked Additions/sec counter in performance counter that, it is showing value for addition of 1000s items.

·         After 5 min., check blue marked Expirations/sec counter in performance counter that, it is showing items going to expire.

·         If the above operations succeed, then you can rest assured that you’ve configured the cache correctly. You can either let the “test data” expire in 5 minutes of manually clear the cache with the following command (again in “%InstallDir%\NCache Express\bin\tools”)

ClearCache cache-id

C:\Program Files\NCache Express\bin\tools > ClearCache mytestreplicatedcache

·         Open web application in visual studio add reference of "Alachisoft.NCacheExpress.Web.dll" from C:\Program Files\NCache Express\bin\assembly\clr20

·         Mark all entities that need to be cached as [Serializable].

Please leave your comments or share this guide if it’s useful for you.

No comments:

Post a Comment