The ASP.NET Cache Object

In "classic" ASP many developers used the Application object as a cache. They stuck everything from single variables to the whole files in there, and when they updated the information, they then forced a refresh of the entire Web application to update the Application object. Not only was this like a using a sledgehammer to crack a nut, it was a memory intensive way of doing thing and the more junk that was accumulated in the application object, the more sluggish your web server would become.

The Cache object is a large feature addition to ASP.NET and seems to have been hidden away in the documentation. Despite initially appearing daunting, there's no reason why anyone can't use it. This is a tutorial on how to add and remove items from the Cache object both implicitly and explicitly, using the dependencies or timestamp expiration policies which mean that you can force the contents of the cache to be expired and then reload them if either a specific date/time is reached, the timestamp on a file changes, or if an item inside the cache itself changes.

$2.89
- OR -

Overview

Table of Content:

  • Creating a Cache
  • Retrieving Information From the Cache
  • Removing Information From The Cache
  • How To Expire Information In the Cache Object
    • TimeStamp Expiration
    • File Dependency
    • Key Dependency
  • Cache Priorities
  • Locking The Cache
  • An example using Caching and File Dependencies
  • An example using Caching and Key Dependencies
  • Summary

Chris Ullman

Chris UllmanChris Ullman is an ex-Wrox Press and Glasshaus author who has spent many years stewing in ASP/ASP.NET, like a teabag left too long in the pot. Coming from a Computer Science background, he started initially as a UNIX/Linux guru, who gravitated towards MS during the summer of ASP (1997). Since then he has written on over 20 books, as lead author for the bestselling Beginning ASP/ASP.NET series, and has contributed chapters to books on PHP, ColdFusion, JavaScript, Web Services, C#, XML and other Internet-related technologies too esoteric to mention, now swallowed up in the quicksands of the dot.com boom. Quitting Wrox in August 2001, he continued life as as a freelance developer and author while helping to bring up his first child, Nye.

See All Postings From Chris Ullman >>

Reviews

Be the first to write a review

You must me logged in to write a review.