Cache datatable [modified]
-
Hello, I am writting an aplication in VB.NET (not a website) I would like to cache a datatable to save time when loading program, I will fill the datatable according to cache. Here my code: Imports System.Web.HttpRuntime dtSynchronize = DirectCast(Cache("dtSynchronize"), DataTable) If dtSynchronize Is Nothing Then dtSynchronize = New DataTable dtSynchronize.Columns.Add("EntryID", System.Type.GetType("System.String")) dtSynchronize.Columns.Add("SyncData", System.Type.GetType("System.String")) dtSynchronize.Columns.Add("StoreID", System.Type.GetType("System.String")) End If dtSynchronize.Rows.Clear() dtSynchronize.Rows.Add("1", "2", "3") Cache.Insert("dtSynchronize", dtSynchronize) It works fine but when I am closing the application and opening it again, I expect that after the first line of code the dtSynchronize will not be Nothing but it is. The cache is not saved. Thank you
Shay Noy
modified on Tuesday, September 8, 2009 5:41 AM
-
Hello, I am writting an aplication in VB.NET (not a website) I would like to cache a datatable to save time when loading program, I will fill the datatable according to cache. Here my code: Imports System.Web.HttpRuntime dtSynchronize = DirectCast(Cache("dtSynchronize"), DataTable) If dtSynchronize Is Nothing Then dtSynchronize = New DataTable dtSynchronize.Columns.Add("EntryID", System.Type.GetType("System.String")) dtSynchronize.Columns.Add("SyncData", System.Type.GetType("System.String")) dtSynchronize.Columns.Add("StoreID", System.Type.GetType("System.String")) End If dtSynchronize.Rows.Clear() dtSynchronize.Rows.Add("1", "2", "3") Cache.Insert("dtSynchronize", dtSynchronize) It works fine but when I am closing the application and opening it again, I expect that after the first line of code the dtSynchronize will not be Nothing but it is. The cache is not saved. Thank you
Shay Noy
modified on Tuesday, September 8, 2009 5:41 AM
I found other solution by storing the datatble in a file and it works fine. Although, if someone has solution for storing it in a cache, please advise Thank you
Shay Noy
-
I found other solution by storing the datatble in a file and it works fine. Although, if someone has solution for storing it in a cache, please advise Thank you
Shay Noy
-
As a cache is only an area of memory it will disappear when your application closes unless you save it to disk or a database
Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
Thank you, I understood it later, I though it is the same cache like in ASP.net.
Shay Noy