By Sriram Mannava
In this article, let's look at how we can configure and use NCache for query caching in Entity Framework Core with an illustrating example in ASP.NET. Caching is one of the most important strategies used for boosting application performance. It is a technique in which certain type of data is maintained in a high speed memory and is accessed whenever a request for that data arises. Caching is applied at various levels of application – for example, web browsers cache content based on the headers sent out by the API / Server via the response.
Other types of Caching includes application data caching, where frequently accessed application data is cached at particular location (for example, in-memory) so that when that particular record or object is needed, it doesn’t need to be fetched again. This avoids an actual database hit and contributes to overall request turnaround time.
Read full ArticleObject Relational Mappers aka ORMs use caching to improve query and database performance. Generally they maintain two levels of caches – a Level 1 Cache and an optional Level 2 Cache.
A Level 1 Cache generally stores all the entities that are touched down by transactions in a session. This is an implicit mechanism used to boost performance and for persistence purposes. Whereas a Level 2 Cache is an optional handle which can be plugged to any third-party cache provider by the developer for further optimizing the query performance.
With a Level 2 Cache, the ORMs can persist query results based on the queries being run onto the database and reuse the stored datasets for consecutive calls, thereby avoiding unnecessary database calls and costs.
Read full Article