Reputation: 45
I have ASP.NET MVC application, where I keep all of drop down values in a table. So on average every page accesses this table 2-3 times. I want to cache (load into memory) this table on application startup.
Is there a way to do so? I have googled, but helpful topics found.
Thanks in advance.
Upvotes: 3
Views: 3211
Reputation: 2828
Would loading it into a static variable do it for you?
You could populate it via the static constructor of whatever class your variable was contained in.
Sidenote: Have you tried just populating the drop down values dynamically on each page load? Was curious if this was a case of pre-optimizing that might not be necessary.
Upvotes: 0
Reputation: 1039080
You could use the built-in cache. As far as the application startup is concerned you could use the Application_Start
method in global.asax
.
Upvotes: 3