Cache.Add not adding

  • Thread starter Thread starter Ismail
  • Start date Start date
I

Ismail

I have asp.net20 web application in my class file in app_code i have
the following code:


HttpContext.Current.Cache.Insert("CampaignImage",
path, null, cacheD,
Cache.NoSlidingExpiration
);

the function where i am doing this is called from home page on my
site. the first time round it gets added to the cache (basically i
have if statement to say if not in cache then add to cache) I can see
it gets added. Now when i refresh the page the item has been dropped
from cache. Am I doing something stupid?

Many thanks


Ismail
 
Ismail said:
I have asp.net20 web application in my class file in app_code i have
the following code:


HttpContext.Current.Cache.Insert("CampaignImage",
path, null, cacheD,
Cache.NoSlidingExpiration
);

the function where i am doing this is called from home page on my
site. the first time round it gets added to the cache (basically i
have if statement to say if not in cache then add to cache) I can see
it gets added. Now when i refresh the page the item has been dropped
from cache. Am I doing something stupid?

Many thanks


Ismail

Does cacheD contain a date in the future?

Is path a very large value so that it might be dropped because of that?
 
Goran,

cacheD is date 1 week in future and path is string no bigger than
20chars.

Regards

Ismail
 
Ok,

Fixed this thanks to help for me mate matt the code should be

HttpContext.Current.Cache.Insert("CampaignImage",
path, null, cacheD,

Cache.NoSlidingExpiration,System.Web.Caching.CacheItemPriority.NotRemovable
, null
);

This being the important bit
System.Web.Caching.CacheItemPriority.NotRemovable

Regards

Ismail
 
Back
Top