kevyou
2/28/2006 4:30:00 PM
i'm having the same problem in web services, the second call see's my cached objects removed. But interestingly I set test string to the Cache (="ttt")
and that stays 'live'
Changing to Application["cacheobject"]=object keeps the cache items alive as expected, so I assume something is desperately wrong with the Cache object.
In debug mode just before I access the Cache object for the secod time it is still in there, but when I do object o = (object) Cache["cacheobject"] it returns Null!!!
>I'm having a similar problem. To investigate, I added a callback method
> to be called when the cache was removed and I wrote out the "Reason".
> It was underused. It seems that in XP on my machine, if I'm running
> other apps including VS2005, asp.net thinks the memory is low and it
> free's up my cache item pretty much instantantly. I have 1GB of memory
> so I'm not sure what exactly the problem it and the cache item is not
> that big. If anyone knows how to fix this, I'd appreciate some advice.
>
> cheloman12 wrote:
> > Hi,
> > I'm using System.Web.Caching.Cahe to mantain a datatable object in an
> > asp.net user control.
> > this is de code i'm using:
> >
> > //In the load event call LoadData method
> >
> > protected void Page_Load(object sender, EventArgs e)
> > {
> > LoadData();
> > this.DataBind();
> > }
> >
> > //In LoadData brings a datatable from database and inserts it to the cache
> > object if it doesn't exist previously. Later it should by retrieved from the
> > cache object.
> >
> > private void LoadData()
> > {
> > if (!this.Page.IsPostBack || Cache["Data"] == null)
> > {
> > Interfaz.Datos oInterfaz = new Interfaz.Datos();
> > dtData = oInterfaz.BringData(UserID);
> > Cache.Insert("Data", dtData, null,
> > System.Web.Caching.Cache.NoAbsoluteExpiration,
> > TimeSpan.FromMinutes(Session.Timeout));
> > }
> > else
> > {
> > dtData = (DataTable)Cache["Data"];
> > }
> > dvData = dtData.DefaultView;
> > gvData.DataSource = dvData;
> > }
> >
> > The problem is that the second time the page executes, Cache["Data"]
> > contains null.
> >
> > I use this concept of caching from asp.net 1.1 and it works fine.
> >
> > Someone knows why cache loses its objects?
> >
> > Best Regards
> > Marcelo
>
>
___
Newsgroups brought to you courtesy of www.dotnetjohn.com