ASP.NET 4.0 Cache Extensibility


Published on

ASP.NET 4.0 Cache Extensibility.

Published in: Technology
1 Comment
1 Like
  • I would like to download This PPT this is mail ID
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

ASP.NET 4.0 Cache Extensibility

  1. 1. ASP.NET 4.0 Cache Extensibility<br /> Stefan SchackowProgram Manager<br /> Microsoft Corporation<br />PC41<br />
  2. 2. What&apos;s the current state?<br />Why is it changing?<br />How are we changing it?<br />.NET Framework Caching<br />
  3. 3. A great in-memory object cache in ASP.NET<br />Lots of configurable &quot;knobs&quot;<br />Expiration policies<br />Automatic scavenging behavior<br />Before and after removal callbacks<br />Extensible cache dependencies<br />Output caching of ASP.NET content<br />Pages <br />Fragment caching of ASP.NET controls<br />Donut caching with cache substitution<br />Output caching of arbitrary HTTP response<br />Current Cache Functionality<br />
  4. 4. In-memory cache has various constraints<br />Object cache API exists in System.Web<br />Awkward to use object cache outside of ASP.NET<br />Common question: Why do I have to include System.Web.dll in my WPF/Winforms project?<br />Not available in 3.5 SP1 Client SKU<br />Caching is a &quot;black box&quot;<br />Where can vendors and developers plugin?<br />Memcached, Velocity, ScaleOut, etc… have no clean integration point available to them<br />Output caching is completely opaque<br />Each custom caching solution is a completely different API for developers to learn<br />Why Make Changes?<br />
  5. 5. Proposed New Cache Functionality<br />A new, extensible, object cache API in its own namespace and assembly<br />Supports both client and server applications<br />Can be made available on both desktop and client SKUs<br />A factored version of the ASP.NET cache engine<br />Extensible ASP.NET output caching<br />Consistent APIs for programming against<br />Disk-based output caches<br />Custom object caches<br />Cloud-based object caches<br />Distributed object caches<br />
  6. 6. New 4.0 Cache Functionality<br />Namespace System.Caching<br />{<br />In-memory<br />Disk based<br />Cache<br />Windows Azure<br />CacheProvider<br />Distributed<br />}<br />
  7. 7. New 4.0 Cache Functionality<br />Namespace System.Caching<br />{<br />CacheItemPolicy<br />(expirations, priority, callbacks)<br />CacheItem<br />Cache<br />CacheItem<br />CacheItem<br />CacheDependency<br />(Sql, Key-based, File)<br />}<br />
  8. 8. Object Caching<br />demo <br />
  9. 9. New 4.0 Output Cache Functionality<br />Namespace System.Web.Caching<br />{<br />Default.aspx<br />In-memory<br />Disk based<br />Foo.ascx<br />Windows Azure<br />OutputCacheProvider<br />Distributed<br />}<br />
  10. 10. Output Caching<br />demo <br />
  11. 11. Core Versus Optional APIs<br />Cache API is a &quot;union&quot; of common functionality<br />Not all cache providers need to implement all features<br />Core functionality for all providers<br />Represented on CacheProvider base type<br />Storing and retrieving a key-value pair<br />Basic Add/Get/Set/Contains/Remove methods<br />Named cache partitions<br />Providers specialize by deriving from<br />InMemoryCacheProvider<br />OutOfProcessCacheProvider<br />
  12. 12. InMemoryCacheProvider<br />Represents a provider running exclusively in a single app-domain<br />Count of items in cache<br />Sliding expirations<br />Distributed caches usually can&apos;t synchronize sliding expiration values across multiple servers<br />Cache dependencies (derivations of CacheDependency)<br />Distributed caches may have no concept of dependencies<br />Item removal callbacks (before and after removal)<br />Distributed caches may not be able to call back to anything<br />
  13. 13. OutOfProcessCacheProvider<br />Represents a provider that stores data outside of an app-domain<br />Version-based updates (CacheItem.Version)<br />Useful for caches that support optimistic concurrency<br />Lock-based updates (CacheItem.LockHandle)<br />If a cache supports pessimistic concurrency<br />Get multiple items<br />Saves multiple round-trips on fetches<br />Query-tag metadata (CacheItem.QueryTags)<br />Retrieving multiple cache items based on string tags<br />
  14. 14. &quot;Velocity&quot; Integration<br />&quot;Velocity&quot; – codename for distributed cache created by the Sql Server team<br />Planned &quot;Velocity&quot; integration points<br />OutOfProcessCacheProvider implementation for object caching<br />SessionStateStoreProviderBase implementation for ASP.NET session state<br />Sidenote: Updates to session state API are planned in 4.0 to allow for more granular sets and gets.<br />OutputCacheProvider implementation for ASP.NET output caching<br />
  15. 15. Checking cache capabilities<br />demo <br />
  16. 16. Migrating From Existing APIs<br />System.Web.Caching.Cache<br />Current plan is that it stays un-changed<br />Might enable &quot;opting-in&quot; to using an object cache provider<br />Requires developing a “shim” that can re-route calls to the new object cache provider layer<br />Currently the “shim” is only in the “idea phase”<br />ASP.NET output caching<br />Both page and control caching can opt-in to using custom providers<br />By default both types of output caching continue to use ASP.NET’s in-memory cache<br />
  17. 17. Migrating From Existing APIs<br />ASP.NET control output caching<br />&lt;@OutputCacheoutputCacheProvider=&quot;…&quot; /&gt;<br />ASP.NET page output caching<br />Programmatically choose different providers <br />Override a new method on HttpApplication<br />HttpApplication.GetOutputCacheProviderName<br />Custom page output caching supports:<br />Absolute expirations<br />File-based dependencies only<br />Validation and substitution callbacks must be static<br />
  18. 18. Migrating From Existing APIs<br />
  19. 19. Summary<br />4.0 Caching is all about extensibility!<br />Both object caching and ASP.NET output caching will be pluggable<br />New object cache APIs available for both client and full versions of .NET Framework<br />
  20. 20. Related Content<br />Breakout Sessions/Chalk Talks<br />PC21 – ASP.NET MVC<br />PC30 – ASP.NET Dynamic Data<br />PC31 – ASP.NET and Jquery<br />PC32 – ASP.NET Ajax Futures<br />PC33 – Microsoft Visual Studio: Easing ASP.NET WebDev<br />PC41 – ASP.NET Cache Extensibility<br />TL48 – Microsoft Visual Studio: Web Development Futures<br />ES15 – Deploying Web Applications with Microsoft Internet Information Services 7.0 and the Web Deployment Tool<br />
  21. 21. Evals & Recordings<br />Please fill out your evaluation for this session at:<br />This session will be available as a recording at:<br /><br />
  22. 22. Please use the microphones provided<br />Q&A<br />
  23. 23. © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.<br />The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.<br />