1-click AWS Deployment 1-click Azure Deployment
- Overview
- Features
- AWS
- Videos
Overview
NCache is a 100% Native .NET Open Source distributed cache (released under Apache License, Version 2.0). NCache provides an extremely fast and linearly scalable distributed cache that caches application data and reduces expensive database trips. Use NCache to remove performance bottlenecks related to your data storage and databases and scale your .NET and Java applications to extreme transaction processing (XTP).
NCache ships with a rich set of features, such as fixed-time and idle-time expiration of cached data, Least-Recently-Used (LRU), Least-Frequently-Used (LFU), priority-based eviction policies, and intelligent relationship management through file- and key-based dependencies. A main advantage of this product is that it ships with a common API for both local and clustered environments, which will certainly help you reduce the learning curve if you want to explore this product in detail.
The NCache API is the core part of the product, while NCache Service and NCache Manager Application provide the facility to create clusters and caches. These utilities are automatically installed at the time of setup. The API provides all the functionality to incorporate various user needs associated with caching.
You must follow certain steps to get started with the product. First, create a new ASP.NET project and add reference to Alachisoft.NCache.Web. You need to import the Alachisoft.NCache.Web.Caching namespace into your application and inherit Alachisoft.NCache.Web.UI.NPage instead of System.Web.UI.Page. The next step is to initialize the cache in your Web application, as shown here:
You are now ready to use the cache in your application, and you can easily add, remove, and fetch the items from the cache. The product comes with a sample tutorial application that will explain the above scenario in detail. The product also ships with a utility called Keep Alive, which will automatically send an http request to the specified URL after the specific time interval. It also ensures that your application never times out by keeping the sessions active.
The product ships with sample applications, such as Chat and Guess Game, which you can explore from the Start menu. Unfortunately, I found that the vendor didn t implement validation rules for the sample applications. The application returned a run-time error when I tried to execute Guess Game without entering any data in the textbox. I hope the vendor will fix these issues during the next release of the product. I am pleased to report, however, that AlachiSoft provided excellent support for all the issues within one day of reporting the problems.
The product comes with complete source code and Visual Studio project files for all the sample applications. The product also ships with detailed documentation in HTML format, which you can also locate from the Start menu. The documentation provides comprehensive coverage about hardware and software requirements for working with the product, information about clusters, incorporating cache into your ASP.NET applications, and much more. It also provides help for the sample applications that ship with the product. I would like to see AlachiSoft integrate the documentation with Visual Studio.NET so that developers can easily access the help system while developing applications.
NCache provides the necessary background for performing all the required tasks for the purpose of caching and it is up to you to effectively make use of it in your .NET applications.
NCache comes in two editions, Local and Clustered. The Local edition only supports local caches; the Clustered edition provides support for replicated and partitioned caches. A trial version of the product can be downloaded from the AlachiSoft Web site. It will be fully active for two full months; after that you can purchase the product directly from the vendor. The pricing of NCache is a little high, but you ll find real use of this product if you are developing large and critical .NET applications.
NCache has been the market leader in .NET Distributed Caching for the last 10 years. It is a very popular and mature product with hundreds of high end customers all over the world relying on it for their application scalability needs.
NCache Session Properties
Exclusive Session Locking: NCache Session Management enhances ASP.NET Core Sessions by providing exclusive session locking to avoid deadlock and data integrity being compromised. Locking is configurable and by default is off.
Locking Release Retry: If an exclusive lock is used, locking retries are also configured. In case of concurrent requests, lock release is tried a configured number of times.
Location Affinity: NCache’s Session Management Services provide Location Affinity which manages ASP.NET Core Sessions across multiple web farms which are geographically separated. For Location Affinity, one ‘primary’ and one or more ‘secondary’ caches have to be specified for each web farm. The primary cache will be used for all local traffic, in local region and secondary cache(s) are of distant geographical regions. These are configured in Web.config.
Cluster Topologies: For sessions, different clustering topologies offered by NCache can be used. Replicated topology offers load balancing of client so that the ASP.NET Core application does not suffer during intensive traffic. If partitioned-replicated cache is used, it provides higher scalability and reliability to the application and performs faster transactions.
Reliability: By default, a session is stored in-memory of an ASP.NET process. If the process recycles or an application server goes down, session data is lost. With NCache, session data is stored outside the ASP.NET process, in a cache cluster. Any cache topology can be opted to meet the needs of reliability. So in case of application server unavailability, session data remains available when the ASP.NET process recycles back or application server becomes live again.
Scalability: NCache Session uses in-memory cache as storage, where a clustered cache provides even better scalability. Working in a clustered environment allows adding more servers to session cluster at runtime; this results in more scalability and reliability for the application. Hence ASP.NET session clustering for web farms is faster and more scalable than storing them in a database.
Availability, Load Balancing, Fault Tolerance: In a web farm environment, using NCache with ASP.NET Core Sessions provides better fault tolerance, keeping session data available at all server nodes in a clustered cache. This also results handling larger load because sessions can be distributed to multiple servers in the farm.
Session Lookup in Cache Made Easy: All session data in cache can be retrieved in a single call through HttpContext.Session
in ASP.NET Core.
Better Performance: Session data being stored in in-memory cache, closer to the ASP.NET application, yields maximum performance.
Although ASP.Net Core lacks a cache object, it provides support for several different types of caching including in-memory caching, distributed caching, and response caching. An open-source product provided by Alachisoft, NCache is an extremely fast, in-memory, distributed, scalable caching framework for use in .Net applications.
NCache is 100-percent native .Net. It is not only faster than Redis, but also provides several distributed caching features that are not supported by Redis. You can learn more about the differences between NCache and Redis here. This article will discuss how we can work with NCache in ASP.Net Core applications.
Windows Installation
NCache can also be installed via an interactive Windows installer by following these steps:
- Search for Command Prompt on Windows Start menu. Right click on the search result “Command Prompt”, and select Run as Administrator. The reason for this is that NCache must be installed from an “admin” user.
- Install NCache: Run “msiexec.exe” utility from Command Prompt to install NCache in an interactive mode as following. Please note that the .msi file may have a different name for .NET Core installation.
msiexec.exe /I "C:\NCacheSetupPath\ncache.ent.x64.msi"
- The following Welcome to the NCache Installation Wizard screen appears:
- Click Next.
- The next screen asks you to accept the license agreement.
- By clicking I accept the terms in the License Agreement, you are making a legal commitment to abide by the Alachisoft Software Agreement for NCache. You cannot proceed without accepting the license agreement.
- Click Next.
- The Select NCache Installation Type appears. Note that Developer edition is only provided for .NET.
- Select the installation option that you want (Cache Server for now) and click Next.
- Cache Server installs the full server product along with the local client.
- Remote Client installs remote client libraries including ASP.NET session modules. It also installs an OutProc local cache and client cache.
- Developer installs standalone local cache and development libraries, along with restricted access to remote caches. Note the following limitations for Developer Installation Type while connecting to remote caches:
- Throttling of 100 requests/sec for each client: All such clients that are licensed under DEV license will not be able to make more than 100 requests/sec to the remote cache.
- Limited number of requests (200,000) a client can send to remote cache: In a lifetime of client application in case it is licensed under DEV license, the client will stop making requests to remote cache after it has sent 200,000 requests to remote cache. Once the client has made 200,000 requests, a licensing exception will be thrown saying “Clients running under DEV license cannot send more than 200,000 requests to remote cache.”
- Click Next.
- Evaluation Information dialog appears which asks for the installation key. (For Cache Server Only)
- This is the key which you have received from Alachisoft when you registered to download NCache Enterprise Edition.
- If you do not have the Install Key, then click Get Evaluation Key. Registration page from Alachisoft website is displayed. Enter all the required information and press Register or Login and an Install Key is emailed to you. Then, enter that Install Key in the above dialog.
- User Information dialog appears which asks for your information. Enter all required information and then press Next.
NOTE
Make sure that the email address provided is the one used during registration with Alachisoft.
- The next dialog confirms the location where NCache should be installed. Keep the defaults or change if you must. Click Next.
- The next dialog presents all the features and allows you to unselect any feature. We recommend that you keep all the features and press Next
. - And, then press Install on the next dialog.
- After the installation is completed successfully, the following dialog is displayed. If you don’t see this dialog then it means the installation did not complete successfully
- .
- Click Finish to exit the installation setup.
- You can refer to Getting Started to get to get you started with setting up NCache environment.
Install/Uninstall NCache Enterprise for Linux
Install NCache (Server/Client)
NCache Enterprise .NET Core provides a tar.gz file (for Linux) for installation through terminal.
NOTE
.NET Core 3.0 is a pre-requisite for installing NCache .NET Core.
- Download the NCache tar.gz file and place it on your desired location.
- In the terminal, extract the tar.gz file through the following command:
tar -zxf <Path to tar.gz file>
NOTE
After extraction, the installation scripts are placed in the folder named ncache-enterprise-5.0-dotnet
.
- In the terminal, go to the directory where NCache installation script is placed.
cd ncache-enterprise-5.0-dotnet
NOTE
The sudo
command grants you the Admin rights and privileges to run NCache scripts.
- For detailed installation usage, run the following command in Linux terminal:
sudo ./install -h
Install NCache Server Mode
For NCache’s server mode installation, run the following command. Notice that -m 0
indicates “Cache Server” installation.
NOTE
Make sure that the email address provided is the one used during registration with Alachisoft.
sudo ./install -f John -l Smith -e johnsmith@alachisoft.com -c Alachisoft -k XXXXXXXXXXXXXXXXX -m 0
Install NCache Client Mode
Installing NCache Client involves the same steps as for the Server mode. To differentiate, simply write -m 3
instead of -m 0
.
NOTE
Make sure that the email address provided is the one used during registration with Alachisoft.
sudo ./install -f John -l Smith -e johnsmith@alachisoft.com -c Alachisoft -m 3
WARNING
If you miss any of these fields, an installation error will occur.
- This will initiate NCache installation and once it is completed, a message will be displayed saying
Installation completed successfully
.
NOTE
NCache is installed in the /opt/ncache
folder by default.
Once NCache is installed, the NCache service will start running automatically.
Uninstall NCache (Server/Client)
For uninstallation, go to the ncache-enterprise-5.0-dotnet
directory where all the necessary scripts are placed.
cd ncache-enterprise-5.0-dotnet
- In the terminal, execute the following command:
sudo ./uninstall
- You will be asked with a Yes/No question to confirm uninstallation. Simply reply with
y
.
.NET Core Installation Properties
The following properties are supported by NCache installation by tar.gz
:
Switch/Properties | Purpose | Default Value |
---|---|---|
-k (Required) |
The key you are provided with upon downloading NCache. | – |
-m (Required) |
Specifies the installation type. Possible values are:
|
0 (Cache Server) |
-f (Required) |
Your first name | – |
-l (Required) |
Your last name | – |
-c (Required) |
Your company name | – |
-e (Required) |
Your email address which is used during registration with Alachisoft. | – |
NCache Open Source on cloud for AWS