Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use System.Runtime.Caching.MemoryCache in a web app?

Tags:

.net

asp.net

System.Runtime.Caching.MemoryCache is described as a kind of System.Web.Caching.Cache for use in non-web applications, but what's the difference? Is there a reason not to use System.Runtime.Caching.MemoryCache in an ASP.Net application?

like image 973
Nick Higgs Avatar asked Jan 29 '26 12:01

Nick Higgs


1 Answers

I believe System.Runtime.Caching is actually newer, and is modeled after System.Web.Caching, the difference being that you don't have to depend on the System.Web assembly. Also, System.Runtime.Caching.MemoryCache is extensible, whereas you cannot inherit from System.Web.Caching.Cache

My suggestion is that if you have a common library that is, say, used for both web AND a service (for example), go with System.Runtime.Caching so you don't have to include the System.Web fluff (if you don't need it).

Here's some discussion on the topic: dotnet System.Web.Caching.Cache vs System.RUntime.Caching.MemoryCache

MSDN: System.Runtime.Caching Namespace

MSDN: System.Web.Caching Namespace

like image 81
Jeremy Avatar answered Jan 31 '26 02:01

Jeremy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!