Saturday, March 24, 2012

Simple Database Caching Question

I watched Scott Stanfield's video "How Do I: Make use of Caching?" He showed how to do data caching with the one table in the NorthWinds database. I have a many-to-many relationship with my tables and I need to cache multiple tables? Does anybody know of an easy/simple way to do this?

Thanks in advance

Hmmm.. its really the result sets that you want to cache not the tables. For instance, If you pulled in a list of movies, that result set is probably dependent on a minimum of 3 joined tables, Category, Video and Video Details.

I would cache, Cache["videos_horror"], Cache["vidoes_comedy"], Cache["videos_action"], etc... when people query for them you first check to see if its cached in your retreive method, if its not you re cache it.

This gives you full control and allows you to update cache if anything changes.

If you cache all three tables, how are you going to let your site auto maintain that cache, and how would you query your cache to return the filtered data sets? You really can't, unless you spent months writing this well rounded code to do this. However, I have never heard of it being done this way, and to my knowledge isnt really practiced like that. You really only want to cache tables if they data within them are gong to be static.

Did this help?


0 comments:

Post a Comment