NCache Open Source on cloud

1-click AWS Deployment 1-click Azure Deployment

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.

A distributed cache such as NCache can improve both the performance and scalability of applications. In a distributed cache, the cached data doesn’t reside in the memory of an individual web server. You can add or remove a server without impacting the cache or the cached data. And if any of the servers go down or stop responding, other servers will still be able to retrieve the cached data. This explains why the cached data in a distributed cache can survive server restarts.

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:NCache Windows Installation Welcome screen
  • Click Next.
  • The next screen asks you to accept the license agreement.
  • NCache Windows Installation 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.NCache Windows Installation Type

 

  • 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)NCache Windows Installation Key
  • 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.NCache Windows Installation Registration
  • 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.

NCache Windows Installation User Info

  • The next dialog confirms the location where NCache should be installed. Keep the defaults or change if you must. Click Next.NCache Windows Installation Location
  • 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
    .NCache Windows Installation Features
  • 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
  • .NCache Windows Installation Success
  • 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.

NCache .NET Core Installation

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.

NCache .NET Core Uninstall

.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)
  • 3 (Cache Client)
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

 

Features

NCache Features – Open Source .NET/.NET Core Distributed Cache

.NET Core

NET Core is a cross-platform, open-source platform from Microsoft for creating web apps, microservices, libraries and console applications. .NET Core runs on the popular Windows, Linux, MacOS and Windows Nano Server operating platforms. It is compatible with .NET Framework, Xamarin and Mono via the .NET Standard Library. Furthermore, .NET Core is open source, using Apache 2 licenses and MIT.

NCache .NET Core Client NCache is compatible with applications built using .NET Core (as well as the traditional .NET Framework). The NCache .NET Core Client is included in the distributed cache cluster server software for NCache Enterprise and Community Edition. Customers’ .NET Core apps communicate with the NCache distributed cache cluster via connection first through the NCache .NET Core Clients. The NCache distributed cache cluster operates in the .NET Framework, while the NCache .NET Core Client runs in .NET Core.
With NCache version 4.8 and later, a separate NCache Client license no longer exists. Rather, the .NET Core Client is included in the Enterprise or Community Edition server license(s).
NCache’s .NET Core Clients can run on Windows, using the Enterprise or Community Edition .msi installer and on Linux using an additional .NET Core Client .tar.gz installer.

Virtualization and Containerization

Docker Support NCache fully supports Docker for cache clients, in addition to cache servers. This enables .NET applications deployed in Docker to seamlessly include the NCache Client. Docker support enables deployment of all NCache servers in the caching tier in Docker. And it makes NCache deployment very easy.
NCache Server and NCache Client are both available in the Docker Hub to include in your Docker configuration.

Performance and Scalability

Performance is defined as how fast cache operations are performed at a normal transaction load. Scalability is defined as how fast the same cache operations are performed under higher and higher transaction loads. NCache is extremely fast and scalable.
See NCache Benchmarks for more details.

Cache Performance NCache is an extremely fast distributed cache. It is much faster than going to the database to read data. It provides sub-millisecond response times to its clients.
Cache Scalability Unlike databases, NCache is able to scale out seamlessly and allow you to keep growing your transaction load. On top of this, NCache provides you linear scalability, which means that as you increase your cache servers, your transaction capacity also increases from the original capacity.
Bulk Operations Bulk Get, Add, Insert, and Remove. This covers most of major cache operations and gives great performance boost.
Asynchronous Operations An asynchronous operation returns control to the application and performs the cache operation in the background. Very useful in many cases and improves application performance greatly.
Compression You can specify this in the config. file and change it at runtime and then do a “Hot Apply”.
Compact Serialization NCache generates serialization code and compiles it in-memory when your application connects to the cache. This code is used to serialize objects and it is almost 10 times faster than regular .NET serialization (especially for larger objects). NCache also stores type-IDs instead of long string-based type names in the serialized object so it is much smaller (hence compact). Following enhancements have been made to compact-serialization:

  1. Users can select and de-select the data members to be compact serialized.
  2. Byte arrays are no more serialized.
  3. Compact types are hot-appliable.
Indexes NCache creates indexes inside the cache to speed up various data retrieval cache operations. You can use this with groups, tags, named tags, searching, and more. Expiration and eviction policies also use indexes.
Multiple Network Interface Cards You can assign two network interface cards to a cache server. One can be used for clients to talk to the cache server and second for multiple cache servers in the cluster to talk to each other. Improves your data bandwidth scalability greatly.

 

Cache Elasticity (High Availability)

Cache elasticity means how flexible the cache is at runtime. Are you able to perform the following operations at runtime without stopping the cache or your application?

  • Add or remove cache servers at runtime without stopping the cache.
  • Make cache config changes without stopping the cache.
  • Add or remove web/application servers without stopping the cache.
  • Have failover support in case any server goes down (meaning are cache clients are able to continue working seamlessly).

NCache provides a self-healing dynamic cache clustering that makes NCache highly elastic.

See Dynamic Clustering for details.

Recovery from Split-Brain Split-Brain is a situation where due to temporary network failures between cluster nodes result in multiple sub clusters. Each sub cluster, in this case, has its own coordinator node and does not know about the other sub clusters. This can eventually result in inconsistent data.
With NCache 4.9, users can enable the cache clusters to automatically recover from Split-Brain scenarios.
Cache Client Keep Alive Some firewalls break idle network connections, causing problems in cache client-to-cache server communication in NCache. The Cache Client Keep Alive feature, if enabled on a client node, automatically sends a lightweight packet to the cache servers at a configurable interval (a sort of heart-beat).
These packets are sent only in case of “no activity” between clients and servers and therefore do not interfere with regular client/server traffic.
Dynamic Cache Cluster NCache is highly dynamic and lets you add or remove cache servers at runtime without any interruption to the cache or your application.
Peer to peer architecture This means there is no “master” or “slave” nodes in the cluster. There is a “primary coordinator” node that is the senior most node. And, if it goes down, the next senior most node automatically becomes the primary coordinator.
Connection Failover Full support. When a cache server goes down, the NCache clients automatically continue working with other servers in the cluster and no interruption is caused.
Dynamic Configuration A lot of information can be changed at runtime without stopping the cache or your applications. NCache has a “Hot Apply” feature does this.
Unlimited Cache Clusters NCache allows you can create unlimited number of cache clusters. The only limiting factor is the underlying hardware (RAM, CPU, NICs etc.)

Cache Topologies

Cache Topologies determine data storage and client connection strategy. There are different topologies for different type of uses.
See NCache Caching Topologies for details.

Local Cache You can use NCache as InProc or OutProc local cache. InProc is much faster but your memory consumption is higher if you have multiple application processes. OutProc is slightly slower but saves you memory consumption because there is only one cache copy per server.
Client Cache (Near Cache) Client Cache is simply a local InProc/OutProc cache on client machine but one that stays connected and synchronized with the distributed cache cluster. This way, the application really benefits from this “closeness” without compromising on data integrity.
Mirrored Cache Mirrored Cache is a 2-node active-passive cache and data mirroring is done asynchronously.
Replicated Cache Replicated Cache is active-active cache where the entire cache is copied to each cache server. Reads are super fast and writes are done as atomic operations within the cache cluster.
Partitioned Cache You can create a dynamic Partitioned Cache. All partitions are created and clients are made aware all at runtime. This allows you to add or remove cache servers without any interruption.
Partitioned-Replica Cache Same as Partitioned Cache and is fully dynamic except there is also a “replica” for each partition kept at another cache server for reliability.

WAN Replication

WAN replication is an important feature for many applications are deployed in multiple data centers either for disaster recovery purpose or for load balancing of regional traffic. The idea behind WAN replication is that it must not slow down the cache in each geographical location due to the high latency of WAN. NCache provides Bridge Topology to handle all of this. See WAN Replication for details.

One Active – One Passive Bridge Topology Active-Passive
You can create a Bridge between the active and passive sites. The active site submits all updates to the Bridge which then replicates them to the passive site.
Both Active Bridge Topology Active-Active
You can create a Bridge between two active sites. Both submit their updates to the Bridge which handles conflicts on last update wins rule or a custom conflict resolution handler provided by you. Then, the Bridge ensures that both sites have the same update.
Switch between Active/Active and Active/Passive While adding caches to bridge, you can configure a cache to participate as an active or a passive member of bridge. Even when bridge is up and running, you can turn a passive into active and an active into passive without losing any data.
User experience to configure a bridge is also changed as the topologies in bridge can be switched between Active-Active to Active-Passive at any time.
Connect/Disconnect Caches Cache administrators can temporarily connect and disconnect caches from the bridge while bridge is running. When a cache is disconnected, no data is transferred between bridge and the disconnected cache. Similarly, the cache on the other side of the bridge stops queuing data to the bridge as the disconnected cache is no more receiving any data.
Cache can be reconnected at any time.

Cache Administration and Management

Cache administration is a very important aspect of any distributed cache. A good cache should provide the following:

  • GUI based and command line tools for cache administration including cache creation and editing/updates.
  • GUI based tools for monitor the cache activities at runtime.
  • Cache statistics based on PerfMon (since for Windows PerfMon is the standard).
  • NCache provides powerful support in all these areas.

See Admin Tools for details.

Thin NCache Manager Project Files The GUI-based NCache management tool (called NCache Manager) used to retain cache configuration information inside its project file. This caused data integrity issues if multiple cache configuration modifications were input on different machines. To avoid this, NCache Manager no longer stores any cache configuration information inside its project files. Instead, all configuration information is kept on common cache servers, accessed from any location.
Total Cache Management Through PowerShell NCache has a rich set of command line tools (along with powerful GUI-based management tools). With NCache 4.8 and later, all NCache command-line cache management tools are implemented in PowerShell, allowing for very sophisticated cache management.
Visual Studio Integration NCache allows yoyu to perform basic management and configuration operations within the Visual Studio. With NCache 4.4 SP2 and later, the Developer installation comes with an ‘NCache Manager’ extension which helps developers manage NCache from Visual Studio. Visual Studio 2010/2012/2013/2015/2017 are supported by NCache.
Cache Admin GUI Tool NCache Manager is a powerful GUI tool for NCache. It gives you an explorer view and lets you quickly administer the cache including cache creation/editing and many other functions.
Cache Monitoring GUI Tool It lets you monitor NCache cluster wide activity from a single location. It also lets you monitor all of NCache clients from a single location. And, you can incorporate non-NCache PerfMon counters in it for real-time comparison with NCache stats.
PerfMon Counters NCache provides a rich set of PerfMon counters that can be seen from NCache Manager, NCache Monitor, or any third party tool that supports PerfMon monitoring.
Graceful Node Stop A node can now be gracefully stopped in a cluster. This action will make sure that all client requests that have reached the node are executed on cache before it comes to complete stop. Similarly, all write behind operations pending in the queue at that time are also executed on the data source. However, no more client requests are accepted by this node.
ReportView Control There is another type of dashboard available in NCache Monitor now that allows you to create a report view style dashboard. In this dashboard, we have two report controls. One is for cache server nodes, while other one for client nodes.
Users can drop the counters in this control and their values are shown in a report view style as shown in PerfMon.
Logging of Counters Counters added in report view can also be configured to be logged. Users can start and stop logging at any time. They can also schedule the logging to start automatically by specifying the start and stop time. These log files are generated in .csv format.
Command Line Admin Tools NCache provides a rich set of command line tools/utilities. You can create a cache, add remote clients to it, add server nodes to it, start/stop the cache, and much more.

Security & Encryption

Many applications deal with sensitive data or are mission critical and cannot allow the cache to be open to everybody. Therefore, a good distributed cache provides restricted access based on authentication and authorization to classify people in different groups of users. And, it should also allow data to be encrypted inside the client application process before it travels to the cache cluster.
NCache provides strong support in all of these areas.
See Security and Encryption Features for details.

Transport Level Security (TLS) 1.2 All communication from NCache clients to NCache servers can now be optionally secured through TLS 1.2 (a newer specification than SSL 3.0). TLS is the same protocol used by HTTPS to ensure a secured connection between the browser and a web server.
TLS 1.2 ensures all data traveling between NCache clients and NCache servers is fully encrypted and secured. Please note that encryption/decryption on NCache clients and NCache servers has a slight performance impact.
Active Directory/LDAP Authentication You can authenticate users against Active Directory or LDAP. If security is enabled, nobody can use the cache without authentication and authorization.
Authorization You can authorize users to as either “users” or “admins”. Users can only access the cache for read-write operations while “admins” can administer the cache.
Encryption (DES & AES) You can enable encryption and NCache automatically encrypts all items inside the client process before sending them to the cache. And decryption also happens automatically and transparently. Currently, 3DES, AES-128, AES-192 and AES-256 encryptions are provided and more are being added.
When encryption is enabled, indexed data is also encrypted.

Object Caching Features

These are the most basic operations without which a distributed cache becomes almost unusable. These by no means cover all the operations a good distributed cache should have.

Get, Add, Insert, Remove, Exists, Clear Cache NCache provides variations of these operations and therefore more control to the user.
Expirations Absolute expiration is good for data that is coming from the database and must be expired after a known time. Sliding expiration means expire after a period of inactivity and is good for session and other temporary data that must be removed once used.
Lock & Unlock Lock is used to exclusively lock a cached item so nobody else can read or write it. This item stays locked until either the lock expires or it is unlocked. NCache also has incorporated “lock/unlock” features in “Get” and “Insert” calls where “Get” returns an item locked and “Insert” updates item and also unlocks it.
Streaming API For large objects (e.g. movie or audio files), where you might want to stream them, NCache provides a streaming API. With this API, you can get chunks of data and pass one chunk upward at a time.

Managing Data Relationships

Since most data being cached comes from relational databases, it has relationships among various data items. So, a good cache should allow you to specify these relationships in the cache and then keep the data integrity. It should allow you to handle one-to-one, one-to-many, and many-to-many data relationships in the cache automatically without burdening your application with this task. See more at managing data relationships.

Key Based Dependency NCache provides full support for it. You can specify one cached item A depends on another cached item B which then depends on a third cached item C. Then, if C is ever updated or removed, B is automatically removed from the cache and that triggers the removal of A from the cache as well. And, all of this is done automatically by the cache.
With this feature, you can keep track of one-to-one, one-to-many, and many-to-many relationships in the cache and invalidate cached items if their related items are updated or removed.
Multi-Cache Key Dependency This is an extension of Key Based Dependency except it allows you to create this dependency across multiple caches.

Synchronization with Data Sources

Database synchronization is a very important feature for any good distributed cache. Since most data being cached is coming from a relational database, there are always situations where other applications or users might change the data and cause the cached data to become stale. To handle these situations, a good distributed cache should allow you to specify dependencies between cached items and data in the database. Then, whenever that data in the database changes, the cache becomes aware of it and either invalidates its data or reloads a new copy. Additionally, a good distributed cache should allow you to synchronize the cache with non-relational data sources since real life is full of those situations as well. NCache provides a very powerful database synchronization feature.

SQL Dependency NCache provides SqlDependency support for SQL Server. You can associate a cached item with a SQL statement based dataset in SQL Server. Then whenever that dataset changes (addition, updates, or removal), SQL Server sends a .NET event to NCache and NCache invalidates this cached item.
This feature allows you to synchronize the cache with SQL Server database. If you have a situation where some applications or users are directly updating data in the database, you can enable this feature to ensure that the cache stays fresh.
Oracle Dependency NCache provides OracleDependency support for Oracle. It works just like SqlDependency but for Oracle. Whenever data changes in the database, Oracle notifies NCache through Oracle event notification.
Just like SqlDependency, this feature allows you to synchronize the cache with Oracle database.
OLEDB Database Dependency NCache provides support for you to synchronize the cache with any OLEDB database. This synchronization is based on polling it is much more efficient because in one poll, NCache can synchronize thousands of cached items instead of receiving thousands of individual events in SqlDependency.
File Based Dependency NCache allows you to specify a dependency on an external file. Then NCache monitors this file for any updates and when that happens, NCache invalidates the corresponding cached item. This allows you to keep the cached item synchronized with a non-relational data source.
Custom Dependency NCache allows you to implement a custom dependency and register your code with the cache cluster. Then, NCache calls your code to monitor some custom data source for any changes. When changes happen, you fire a dependency update within NCache which causes the corresponding cached item to be removed from the cache.
This feature is good when you need to synchronize the cached item with a non-relational data source that cannot be captured by a flat file. So, custom dependency handles this case.

Runtime Data Sharing

Runtime data sharing has become an important use for distributed caches. More and more applications today need to share data with other applications at runtime in an asynchronous fashion. Previously, relational databases were used to share data among multiple applications but that requires constant polling by the applications wanting to consume data. Then, message queues became popular because of their asynchronous features and their persistence of events. And although message queues are great, they lack performance and scalability requirements of today’s applications.
As a result, more and more applications are using distributed caches for event driven runtime data sharing. This data sharing should be between multiple .NET applications or between .NET and Java applications. NCache provides very powerful features to facilitate runtime data sharing.
See run-time data sharing for details.

Publish/Subscribe (Pub/Sub) with Topic The Publish/Subscribe (Pub/Sub) messaging paradigm is provided where a publisher sends messages into channels, without knowing the subscribers (if any). And subscribers receive only messages of interest, without knowing who the publishers are.
NCache provides named Topic support through which a publisher sends messages to multiple subscribers or to any one among them. And, subscribers can subscribe to a named Topic, and its callback is called by NCache when a message arrives against this Topic.
Events with Data You can specify whether to receive data with the event or only the event. In many situations, you may want the data along with the evet to guarantee that you’re getting the copy that was actually modified. This is because if you don’t receive data with events and your application then fetches the data from the cache, somebody else might have changed this data by that time.
Cached Item Specific Events (onInsert/onRemove) NCache allows you to register interest in various cached items. Then, when these items are updated or removed, your callbacks are called. This is true even if you’re connected to cache remotely.
Cache Level Events (Add/Insert/Remove) NCache allows you to register to be notified whenever any cached item is added, updated, or removed. Your callback is called when this happens even if your application is remotely connected to the cache.
Custom Events (Fired by Apps) NCache allows your applications to fire custom events into the cache cluster. And, other applications can register to be notified for these events.
This feature allows you to coordinate a producer/consumer scenario where after the producer has produced data, it notifies all the consumers to consume it.
Continuous Query NCache provides a powerful Continuous Query feature. Continuous Query lets you specify a SQL-like query against which NCache monitors the cache for any additions, updates, or deletes. And, your application is notified whenever this happens.

Cache Search (SQL-Like)

Distributed cache is frequently used to cache objects that contain data coming from a relational database. This data may be individual objects or collections that are the result of some database query.
Either way, applications often want to fetch a subset of this data and if they have the ability to search the distributed cache with a SQL-like query language and specify object attributes as part of the criteria, it makes the distributed cache much more useful for them.
NCache provides powerful Object Query Language (OQL) for searching the cache with a SQL-like query.
See Object Query Language for details.

Object Query Language (OQL) NCache provides a rich Object Query Language (OQL) with which you can search the cache. Your search criteria can now include object attributes (e.g. cust.city = ‘New York’) and you can also include Tags and Named Tags in the query language.
Group-by for Queries You can issue GROUP BY queries and obtain a result set that includes counts of items in the cache groups by attribute values.
Delete Statement in Queries You can delete cached items by specifying an attribute based criteria.
LINQ Queries NCache allows you to search the cache with LINQ queries. LINQ is a popular object querying language in .NET and NCache has implemented a LINQ provider.

Data Grouping

A distributed cache should be much more than a Hashtable with a (key, value) pair interface. It needs to meet the needs of real life applications that expect to fetch and update data in groups and collections. In a relational database, SQL provides a very powerful way to do all of this.
We’ve already explained how to search a distributed cache through OQL and LINQ. Now let’s discuss Groups, Tags, and Named Tags. These features allow you to keep track of collections of data easily and even modify them.

Groups/Subgroups NCache provides the ability for you to group cached items in a group-subgroup combination (or just group with no subgroup).
You can later fetch or remove all items belonging to a group. You can also fetch just the keys and then only fetch subset of them.
Tags A Tag is a string that you can assign to one or more cached items. And one cached item can be assigned multiple Tags.
And, later, you can fetch items belonging to one or more Tags in order to manipulate them.
You can also include Tags in Object Query Language or LINQ search as part of the criteria.
Named Tags NCache provides Named Tags feature where you can assign a “key” and “tag” to one or more cached items. And, a single cached item can get multiple Named Tags.
Later, you can fetch items belonging to one or more Named Tags.

Read-through & Write-through

Many people use distributed cache as “cache on the side” where they fetch data directly from the database and put it in the cache. Another approach is “cache through” where your application just asks the cache for the data. And, if the data isn’t there, the distributed cache gets it from your data source.
The same thing goes for write-through. Write-behind is nothing more than a write-through where the cache is updated immediately and the control returned to the client application. And, then the database or data source is updated asynchronously so the application doesn’t have to wait for it. NCache provides powerful capabilities in this area.
See Read-through & Write-through for details.

Read-through NCache allows you to implement multiple read-through handlers and register with the cache as “named providers”. Then, when the applications tell NCache to use read-through upon a “cache miss”, an appropriate read-through is called by the cache server to load the data from your database or data source.
Write-through & Write behind NCache allows you to implement multiple write-through handlers and register with NCache as “named providers”. Then, whenever application updates a cached item and tells NCache to also call write-through, NCache server calls your write-through handler.
If you’ve enabled write-behind, then NCache updates the cache immediately and queues up the database update and a background thread processes it and calls your write-through handler.
Write-through & Write- behind batching options You can specify the following:

  1. Batch size – how many items to batch together when doing database updates.
  2. Batch interval – How long to wait before processing the next batch.
  3. Retries threshold – How many retries to do if a database update fails.
  4. Retry queue eviction – How many items to evict from retry-queue if it becomes full.
Reload Items at Expiration & Database Synchronization NCache allows you to specify that whenever a cached item expires, instead of removing it from the cache, NCache should call your read-through handler to read a new copy of that object and update the cache with it.
You can specify the same when database synchronization is enabled and a row in the database is updated and a corresponding cached item would have been removed from the cache. These items are reloaded with the help of your read-through provider.

Cache Size Management (Evictions Policies)

A distributed cache always has less storage space than a relational database. So, by design, a distributed cache is supposed to cache a subset of the data which is really the “moving window” of a data set that the applications are currently interested in.
This means that a distributed cache should allow you to specify how much memory it should consume and once it reaches that size, the cache should evict some of the cached items. However, please keep in mind that if you’re caching something that does not exist in the database (e.g. ASP.NET Sessions) then you need to do proper capacity planning to ensure that these cached items (sessions in this case) are never evicted from the cache. Instead, they should be “expired” at appropriate time based on their usage.

Specify Cache Size NCache lets you specify the upper limit of cache size in MB as per your needs. And you can “Hot-Apply” these changes.
LRU Evictions (Least Recently Used) Least recently used is one of the eviction policies and it means those items that have not been accessed by any client application in the longest time will be evicted from the cache.
LFU Evictions (Least Frequently Used) Least frequently used is one of the eviction policies and it means those items that have been accessed the least number of times since the last eviction or since the starting of the cache, whichever is later, would be evicted.
Priority Evictions NCache lets you specify different priority values when you add an item to the cache. These include high, above-normal, normal, below-normal, and low. When the cache is full and NCache wants to evict items, it starts from priority low and starts evicting all the items in a FIFO (first-in-first-out) manner.
Do not Evict NCache also lets you specify a “do not evict” priority for some cached items and then they are not evicted. This is enabled at cache-level so nothing gets evicted from the entire cache. This is espically useful in case of ASP.NET Session storage.

 

ASP.NET Support

ASP.NET applications need three things from a good distributed cache. And, they are ASP.NET Session State storage, ASP.NET View State caching, and ASP.NET Output Cache. ASP.NET Session State store must allow session replication in order to ensure that no session is lost even if a cache server goes down. And, it must be fast and scalable so it is a better option than InProc, StateServer, and SqlServer options that Microsoft provides out of the box. NCache has implemented a powerful ASP.NET Session State provider.
See ASP.NET Session State for details.
ASP.NET View State caching allows you to cache heavy View State on the web server so it is not sent as a “hidden field” to the user browser for a round-trip. Instead, only a “key” is sent. This makes the payload much lighter, speeds up ASP.NET response time, and also reduces bandwidth pressure and cost for you. NCache provides a feature-rich View State cache.
See ASP.NET View State for details.
Third is ASP.NET Output Cache. For .NET 4.0, Microsoft has changed the ASP.NET Output Cache architecture and now allows third-party distributed caches to be plugged-in. ASP.NET Output Cache saves the output of an ASP.NET page so the page doesn’t have to execute next time. And, you can either cache the entire page or portions of the page. NCache has implemented a provider for ASP.NET Output Cache.

ASP.NET Core Response Caching NCache’s implementation of IDistributedCache utilizes Distributed Cache Tag Helper that provides the ability to dramatically improve the performance of your ASP.NET Core app by caching its responses.
ASP.NET Core Session Provider & IDistributedCache NCache provides full ASP.NET Core support, in addition to the previously available ASP.NET in the .NET Framework.
NCache includes a powerful ASP.NET Core Session Provider that has more features than the regular ASP.NET Session Provider. And, it supports the IDistributedCache interface in ASP.NET Core.
ASP.NET Session State Store NCache has implemented an ASP.NET Session State Provider (SSP) for .NET 2.0+. You can use it without any code changes. Just change web.config.
NCache provides intelligent session replication and is much faster than any database storage for sessions.
ASP.NET View State Cache NCache has an ASP.NET View State caching module. You can use it without any code changes to your application. Just modify web.config.
You can also associate ASP.NET View State to a user session so when that session expires, all of its View State is also removed.
ASP.NET Output Cache NCache has an ASP.NET Output Cache provider implemented. It allows you to cache ASP.NET page output in a distributed cache and share it in a web farm.
Users can now write their own code to modify the cache items before they are inserted in NCache. Users can change the expiration, dependencies, etc. of output cache items by writing these hooks.
For this, users have to implement an interface provided with OutputCacheProvider and then register this assembly and class in web.config.
NCache Backplane for SignalR NCache offers support for SignalR through an extension to the SignalR provider. All concerned web servers for the application are registered against the provider. Meanwhile, the clients are connected to their respective web servers. In NCache, as soon as a client registers itself against the webserver, two key features of NCache come into play: Custom Events and CacheItem.itemVersion.
ASP.NET Core Sessions NCache architecture allows you to scale linearly to handle extreme transaction load by allowing you to add more cache servers at runtime. NCache also provides intelligent cache replication to ensure zero ASP.NET Core Session data loss if a web or a cache server goes down.

Third Party Integrations

Memcached is an open-source in-memory distributed caching solution which helps speed up web applications by taking pressure off the database. Memcached is used by many of the internet’s biggest websites and has been merged with other technologies.
NCache implements Memcached protocol to enable users with existing Memcached implementations to easily migrate to NCache. No code required for this.
See Memcached Wrapper for details.
NHibernate is a very powerful and popular object-relational mapping engine. And, fortunately, it also has a second level cache provider architecture that allows you to plug-in a third-party cache without making any code changes to the NHibernate application. NCache has implemented this NHibernate Second Level Cache provider.
See NHibernate Second Level Cache for details.
Similarly, Entity Framework from Microsoft is also a very popular object-relational mapping engine. And, although Entity Framework doesn’t have a nice Second Level Cache provide architecture like NHibernate, NCache has nonetheless implemented a second level cache for Entity Framework.
See Entity Framework Second Level Cache for details.

Entity Framework Core (EF Core) 2.0 Extension Methods for NCache NCache has very easy to use EF Core 2.0 Extension Methods that cache application data fetched through EF Core 2.0. Although Extension Methods require some minimal coding, it is a small effort and it yields a lot of control over which data to cache and for how long.
Memcached Wrapper Memcached Wrapper for NCache offers you a no-code-change way for migrating your Memcached applications to a powerful elastic distributed cache. You can use Memcached Wrapper for NCache in two ways as following:

  1. Memcached Plug-In (.NET apps)
    Memcached Plug-In option is for .NET applications. Alachisoft has taken all the popular Open Source Memcached client libraries and implemented them for NCache. These libraries for .NET are:

    • Enyim
    • BeIT
    • More…
  2. Memcached Gateway
    Memcached Gateway implements Memcached Protocol and supports all types of Memcached applications. You direct your application to this Memcached Gateway and your application starts using NCache behind the scenes.
NHibernate Second Level Cache NCache provides an NHibernate second level cache provider that you can plug-in through web.config or app.config changes.
NCache has also implemented database synchronization feature in this so you can specify which classes should be synchronized with the database. NCache lets you specify SqlDependency or any OLEDB compliant databased dependency for this.
Entity Framework Second Level Cache You can plug-in NCache to your Entity Framework application, run it in analysis mode, and quickly see all the queries being used by it. Then, you can decide which queries should be cached and which ones to be skipped.
You can also specify which queries should be synchronized with the database through SqlDependency.

 

 

AWS

Installation Instructions For Windows

A) Click the Windows “Start” button and select “All Programs” and then point to NCache Open Source .

B) RDP Connection: To connect to the operating system,

1) Connect to virtual machine using following RDP credentials :

  • Hostname: PublicDNS  / IP of machine
  • Port : 3389

Username: To connect to the operating system, use RDP and the username is Administrator.
Password : Please Click here  to know how to  get password .

C) Other Information:

1.Default installation path: will be on your root folder “C:\Program Files\NCache\”
2.Default ports:

  • Windows Machines:  RDP Port – 3389
  • Http: 80
  • Https: 443

D) Note: Click on Desktop icon – Press start  then App will open in browser.

Configure custom inbound and outbound rules using this link

Installation Step by Step Screenshots

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Videos

NCache Open Source on cloud