NCache 4.6 - Online Documentation


The ADO.NET Entity Framework is a popular object-relational mapping framework. It provide abstraction from the underlying relational data that is stored in a database and presents its conceptual schema to the application.
In most of the high transaction cases, the database quickly becomes a bottleneck. Because in database tier, adding more and more servers cannot scale performance. To achieve this scalability use in-memory cache provider module along with Entity Framework application. Although, Entity Framework does not provide a Second Level Cache provider model but it is flexible to support second Level Cache Provider.
Entity Framework Caching Provider
NCache has implemented a custom ADO.NET provider called as "Entity Framework-Caching Provider" which acts between Entity Framework and the original provider.  NCache provides the features listed below:
  • No Code Change: NCache Entity Framework Caching Provider can be integrated  in  application without any code change. 
  • Better Performance: NCache custom provider intercepts all the database queries calls and puts result-sets of queries in a cache storage. This increases the performance of applications by avoiding expensive databases trips. 
  • Application Scalability : NCache provides a reliable and shared memory resource for storage. It gives the ability for sharing transactional context between different entities in any entity framework application. 
The caching provider can perform various functions, such as:
  • Managing connections, commands, transactions and data read
  • Monitoring queries and commands before they execute.
The following figure shows how and where NCache Entity Framework Provider plugs into an Entity Framework application.
Figure 1. NCache Entity Framework Provider
Entity Framework Caching Integration Modes
There are two execution modes for NCache  Entity Framework Caching Provider:
  1. Analysis Mode
  2. Caching Mode
These modes are mutually exclusive, so NCache Entity Framework Caching Provider cannot execute in both modes at the same time. It can either be in "Caching" mode or in "Analysis" mode
Recommendation: First execute the entity framework application within analysis mode of NCache Entity Framework-Caching Provider.
1. Analysis Mode:
Analysis mode is a pass-through mode, no caching is done at this mode. This mode provides features that are listed as follows: 
  • Monitoring Query: Monitoring the number of times each query is executed by Entity framework Application. This allows the user to determines which queries are most frequent and are the best candidates for caching.
  • Generate Reports:  It generates reports for queries with proper syntax  and also arranging them in descending order. That allows the user to choose suitable queries and copy them for caching. 
2. Caching Mode:
This mode is basically designed for the actual use of NCache in Entity Framework applications. At this point, queries and their result sets are cached. Caching mode only entertains those queries which are given in configuration file i.e. efcaching.ncconf.
See Also