How to cache database tables to prevent many database queries in Asp.net C# mvc -


i build own cms using asp.net mvc 4 (c#), , want cache database data, likes: localization, search categories (it's long-tail, each category have it's own sub , sub-sub categories), etc..

it's overkill query database time, because can more 30-100 queries each page request, users update database rarely

so best way (performance , convenience) it??? (links guides , tutorials also)

i know how use outputcache of action, it's not need in situation , it's cache html, need example, own helper @html.localization("newsletter.tite") take value of language, or helper interact data etc.

i think (not sure) need cache data want, when application invoke first time, , work cache location, don't have experience how it.

you use built-in memorycache store entire resultsets have retrieved database.

a typical pattern:

mymodel model = memorycache.default["my_model_key"] mymodel; if (model == null) {     model = getmodelfromdatabase();     memorycache.default["my_model_key"] = model; }  // use model here 

Comments