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.