B
bas jaburg
I have a class library and a web app. The web app is using objects
from the class lib. I'd like to save data of previously retrieved data
in the class lib, so that the next time i get data from the object it
gets it from its "cache" as opposed to get it from the database again.
The System.Web.Caching.Cache() class only exists in the context of the
web app and this does not work either:
System.Web.Caching.Cache myCache = new System.Web.Caching.Cache() ;
if (myCache ["cachedObject"] == null)
{
result = GetData();
myCache .Insert("cachedObject", result);
}
else
{
result = (object) myCache ;
}
because it will give and "Object reference not set to an instance of
an object" error.
Any help greatly appreciated
Bas Jaburg
www.jaburg.com
from the class lib. I'd like to save data of previously retrieved data
in the class lib, so that the next time i get data from the object it
gets it from its "cache" as opposed to get it from the database again.
The System.Web.Caching.Cache() class only exists in the context of the
web app and this does not work either:
System.Web.Caching.Cache myCache = new System.Web.Caching.Cache() ;
if (myCache ["cachedObject"] == null)
{
result = GetData();
myCache .Insert("cachedObject", result);
}
else
{
result = (object) myCache ;
}
because it will give and "Object reference not set to an instance of
an object" error.
Any help greatly appreciated
Bas Jaburg
www.jaburg.com