Last post Mar 30, 2011 02:30 PM by blakepell
Mar 29, 2011 01:48 PM|blakepell|LINK
Here's the situation. I have some long running database queries that return DataTables that I am caching in the runtime cache (to provide quick paging after the intial query runs). I understand that there is no guarantee that these items will be available
for any set of time regardless of what I specify. My problem is, the cached item in this case can disappear by the next line of code (i.e. one line of code puts it in the cache and it's gone on the next line of code). I can't even guarantee that it's there
for the rest of that specific request. My code goes out to the database if the table doesn't exist in the cache at the beginning of the request.
Performance wise, the cache *greatly* improves the speed of paging. However, in sporadic cases I can't recreate it drops items and then a DataTable will show like it has 0 records when in actuality, it should have data.
My questions are:
1.) Does anybody have any suggestions on how to modify what I have listed above to improve performance/reliability?
2.) What are the other preferred methods for caching? I know the ent library has caching blocks, are there any other good light weight methods?
Mar 29, 2011 08:49 PM|Small Peter|LINK
Hi, each time you want to display the DataTable, first obtain it from the Cache. If it's there, everything is good, as you have already pulled it out, you are sure you have data. If it's not there, load the DataTable from your DB, then update the Cache.
So it could be accessed in the future.
Mar 30, 2011 02:30 PM|blakepell|LINK