Alex Rivera | Logout

Asp.net - Caching vs Static Variable for storing a Dictionary

Asked 2009-08-20T19:35:12.213
21

I am building a web-store with many departments and categories. They are stored in our database and accessed often.

We are using URL rewriting so almost every request within the store generates a lookup. We also need to iterate over the data frequently to generate menus for the main store and the department pages.

This information will not change often so I'm thinking that I should load the database into a dictionary to speed up the information retrieval.

I know the standard practice is to load data into the application cache, however i assume that there is some level of serialization that occurs during caching, and for a large data-structure I'm thinking the overhead would be significant.

My impulse on this is to put the dictionary in a static variable in one of the related classes. I would however like to get some input input on this. Am I right in thinking that this method would be faster? Is it horrible practice? Is there a better way that I'm missing?

I can't seem to find much information on this and I'd really appreciate any information that you can share. Thanks!

Edit
Report

1 Answer

3

memcached is your friend! (but could be overkill if you're not scaling out)

Any idea how large your dictionary would be in application cache? I'd be tempted to recommend that as a good first option.

answered 2009-08-20T19:48:54.043

Your Answer