ASP.NET Caching Strategy

I am working on implementing data caching for commonly used database objects, and I have had difficulty choosing the best caching strategy for the following scenario:

I have a table called Campaigns with 1423 entries. The campaign contains all the texts and settings that describe the landing page. When the landing page is created, the corresponding campaign is retrieved from the database. Some rates are considered more than others.

(Caching output is my next step, so no need to comment on this.)

I think out loud:

A) Load all campaigns up into the dictionary at server startup and put it in the cache.

I calculated that it would take about 3.8 MB of server memory (OK) and take about 8 seconds (OK) on the first pageview with the current number of campaigns. The only problem is that it does not scale very well. Tomorrow I may have 10 times more campaigns. We also need to update and add new campaigns daily, and each Campaign cache every time seems a little redundant.

The nice part of this is that all campaigns are always cached so that there is no launch time when a visited page that has not been visited is available (for example, by a search engine).

B) Lazyloading: cache each campaign individually using a key such as "Campaigns. [Id]"

, , SlidingExpiration, . , , . , .

C) Lazyloading bennefins, B), , , , .

? B).

, , id, ().

:

Campaigns campaign = //Get campaign from database:
Cache["Campaigns.Id."+campaign.Id.ToString()] = campaign; //Id is Guid
Cache["Campaigns.Code."+campaigns.Code] = campaign;

?

+5
1

, ( B), - . , , . - . , 10 , - , , 5-10 .

ASP.NET -:

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/caching/data.aspx

, . , , - . , , , .

, . , (-10, -20 ..). ( , ..).

, , ASP.NET :

http://msdn.microsoft.com/en-us/library/ms228248.aspx

.

+4

All Articles