I dont know if I should use the httpcontext caching or the Enterprise Library Caching Application Block. Also, what is the best pattern for the caching Strategy when deleting or updating an entity that is part of a cached list?
Should I remove all of a list from the cache or only remove the item from the cached list? If I update it will I remove the list from the cache or update the entity in it.
ASP.NET Core works with SQL Server, Redis, and NCache distributed caches. For more information, see Distributed caching in ASP.NET Core. Cache the content from an MVC view or Razor Page with the Cache Tag Helper. The Cache Tag Helper uses in-memory caching to store data.
ASP.NET provides the ability in terms of caching at various levels. 1. Page Level Output Caching This is at the page level and one of the easiest means for caching pages. This requires one to specify the duration of the cache and the attribute of caching.
In the .NET Framework 3.5 and earlier versions, ASP.NET provided an in-memory cache implementation in the System.Web.Caching namespace. In previous versions of the .NET Framework, caching was available only in the System.Web namespace and therefore required a dependency on ASP.NET classes.
In ASP.NET MVC we can specify where we want to cache the content of the action method. To use caching in the action method we use the OutputCache attribute and specify the Duration and VaryByParam arguments. The following code will cache the contents of the action method for 1 minute.
Having done some testing with both I did a full review of the caching application block in the context of our code and blogged my experience with it. It's very simple to use and powerful enough for our needs. I would recommend it, my results were blogged here.
In your position I would use the Repository pattern to maintain my cache, it works well for database datasets and should work equally well for the cache in your own. If you're not familar with the repository pattern, check out this post from Steven Walther.. I would tend to disagree with the previous answer however, taking out only the items you need for modification and laeving the rest untouched. This will allow you to expire items from the cache independantly from the whole list should you so wish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With