Last post Oct 12, 2014 12:22 PM by asad_dba
Oct 11, 2014 05:38 PM|asad_dba|LINK
As I have to fetch master data (approximately 50 records) from database in order to populate into dropdownlist , I believe its costly specially over internet, is there any way we can store them or cache them locally, so each time I don't have to read it
Oct 11, 2014 06:00 PM|markfitzme|LINK
Sure, you can store the results in a dataset or datatable and store that in the application cache. You might want to write a routing though that handles this so you don't have to worry about the cache being missed. Essentially, write a static method to
1) check if cached item exists and if it does, return it
2) if it doesn't exist get it from the database, add the results to the cache, and return the dataset or datatable to then bind to your dropdownlist
Oct 11, 2014 06:07 PM|asad_dba|LINK
please any sample code, how to cache data table for entire application and how to access, what if any changes in master data happen, that's mean each time we have to compare for changes between cache data and stored data in database.
Oct 11, 2014 08:39 PM|oned_gk|LINK
<asp:SqlDataSource ID="SqlDataSourceDDL" runat="server" CacheDuration="12345" EnableCaching="True" ...>
The ddl datasouce dont need to reget the 50 items from database in specific duration.
But you need also to think that client need to get 50 items from server.
If you have large items need to sent from server to client machine, this can causes performace issue.
The browser need to hold large items also.
To handle large items, use category-sub category
Oct 12, 2014 12:22 PM|asad_dba|LINK
thank you for reply , as I am reading connection string from web.config , I can also use CacheDuration="12345" EnableCaching="True" in my case, furthermore can you please celebrate more about category-sub category.