Simple custom cache class…..

One of the projects I'm working in is a large ASP.NET application that will have both Mobile and WinForms bits plugged into it in the future. We want to cache data but we don't want it tied to the ASP.NET cache (even if it will work now without IIS on the machine, it may not work that way in the future). So, we wrote our own simple custom cache. 

The cache is quite simple but does support time based expiration and has a polling mechanism to remove "dirty" items. There isn't anything proprietary about the class so I figured it was ok to send out in the wild. The only thing that you should look out for is that we use a custom configuration class (there are like one or two references to "ProductName.Configuration.Blah" in the code) - you will need to replace those with either hard coded values of your own or configuration items of your own.

At any rate, it's not too complicated but I thought it might be useful to someone out there so I posted it to my site. you can get the complete source for the custom cache class here and the custom cache item class here.

Much credit goes to Ben Tiedt who helped me design the spec for the class and wrote much of the code.


Comments (9)
  1. Roy Osherove says:

    Good one! Thanks 🙂

  2. Jesse Ezell says:

    Well, you already have it written I guess, but the Blue Bricks team is working on a caching block that works across ASP.NET, WinForms, etc. Don’t know if its up there yet…

  3. Alex Lowe says:

    Yeah, we created it about 3 months ago – they’ve been quite slow to push out any new application blocks but I really like the ones that are currently available.

  4. chadb says:

    Blue Bricks? Link?

  5. Alex Lowe says:

    I believe Blue Bricks is the name of the group that is working on Microsoft’s suite of Application Blocks: Data Access Block, Exception Management Block, and a few new ones are in the works but aren’t available yet.

  6. The application blocks are excellent tools…would be nice if they were a bit more transparent as to what they’re doing.

  7. Pradeep says:

    My current project does needs this, we here were just planning to implement the Cache Factory, which I guess my seniors will not be able to do it as they have ignored me ;)). As I also had the similar idea. But my idea still is at beginning stage. Thanx for opening the source code as this thing will help me in future.

Comments are closed.

Skip to main content