Will ASP.Net remove individual tables from the cached dataset to free up memory?

I have a strange, sporadic problem.

I have a stored procedure that returns back 5 small tables (like IDs and text descriptions for status dropdowns). The code calls this and places the returned dataset in the ASP.Net cache. Separate methods are called to retrieve individual tables from a dataset into data binding to controls in my web application.

Only on my QA server one table disappears. The table will be available for one test scenario; however, the next time the same script is executed, one table is null. The table that goes to MIA is always the same (more precisely, table number 4 of 5).

If ASP.Net WP needs memory, can it drop an individual table from the cached dataset while preserving the dataset indexes?

Below is the caching code:

public static DataSet GetDropDownLists()
{
    DataSet ds = (DataSet)HttpContext.Current.Cache["DropDownListData"];

    if (null == ds)
    {
        // - Database Connection Information Here
        ds = db.ExecuteDataSet(CommandType.StoredProcedure, "Sel_DropDownListData");

        HttpContext.Current.Cache.Add("DropDownListData", ds, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero, CacheItemPriority.Normal, null);
    }

    return ds;
}

      

Here's an example of a method that returns a null table:

public static DataTable GetStatusList()
{
    return GetDropDownLists().Tables[3]; 
}

      

Again, this only happens on my QA server, not when my local code is connected to a QA database or anything on a separate server for my own development testing.

thank

0


source to share


2 answers


ASP.NET cache will only work directly on objects that you insert into the IEnumerable list.

If you add a list of <> objects as one item to the cache, it will either keep the entire list or discard the entire list from the cache. It will never enter the list and will not remove individual items from it. The same should be valid for tables in the dataset.



Something else must mess up your dataset. Are you sure that table # 4 is correctly uploaded to your QA server (i.e. is it not empty to start with?)

+4


source


The fact that the DataSet is cached doesn't matter.

The table cannot be removed from the DataSet except explicitly.



You will have to debug to find out what is going on logically with one of:

  • the table has been explicitly removed from the DataSet

  • DataSet was removed from cache and restored without table

+1


source







All Articles