ASP.NET Cache Class - Are there differences between ASP.NET 3.5 and ASP.NET 4.0?
Are there any major differences between the ASP.NET开发者_StackOverflow Cache Class from ASP.NET 3.5 to 4.0?
I don't think there are any major differences; there is a new MemoryCache class though.
ASP.NET 4 adds extensibility to output caching that enables you to configure one or more custom output-cache providers. Output-cache providers can use any storage mechanism to persist HTML content. These storage options can include local or remote disks, cloud storage, and distributed cache engines.
...
Since its first release, ASP.NET has included a powerful in-memory object cache (Cache). The cache implementation has been so popular that it has been used in non-Web applications. However, it is awkward for a Windows Forms or WPF application to include a reference to System.Web.dll just to be able to use the ASP.NET object cache. To make caching available for all applications, the .NET Framework 4 introduces a new assembly, a new namespace, some base types, and a concrete caching implementation. The new System.Runtime.Caching.dll assembly contains a new caching API in the System.Runtime.Caching namespace. The namespace contains two core sets of classes: Abstract types that provide the foundation for building any type of custom cache implementation. A concrete in-memory object cache implementation (the MemoryCache class).
The new MemoryCache class is modeled closely on the ASP.NET cache, and it shares much of the internal cache engine logic with ASP.NET. Although the public caching APIs in the System.Runtime.Caching namespace have been updated to support development of custom caches, if you have used the ASP.NET Cache object, you will find familiar concepts in the new APIs.
http://msdn.microsoft.com/en-us/library/s57a598e.aspx
As an addendum to Raj's answer:
The MemoryCache class is similar to the ASP.NET Cache class. The MemoryCache class has many properties and methods for accessing the cache that will be familiar to you if you have used the ASP.NET Cache class. The main differences between the Cache and MemoryCache classes are that the MemoryCache class has been changed to make it usable by .NET Framework applications that are not ASP.NET applications. For example, the MemoryCache class has no dependencies on the System.Web assembly. Another difference is that you can create multiple instances of the MemoryCache class for use in the same application and in the same AppDomain instance.
http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.aspx
精彩评论