I'm using ASP.NET Cache in my website and recently I've noticed that items in it are still being retrieved after the expiration time has passed.
I'm using Cache.Add()
to add items, and setting the absoluteExpiration
to the current time + 1 second:
ConfigurationObject config = null;
string configKey = moCode + serviceCode + "config" + languageID;
System.Web.Caching.Cache Cache = HttpContext.Current.Cache;
config = (ConfigurationObject)Cache[configKey];
if (config == null)
{
ServiceContractClient serviceClient = new ServiceContractClient();
string result = serviceClient.GetConfiguration(out config, moCode, serviceCode, languageID, "");
serviceClient.Close();
Cache.Add(
configKey,
config,
null,
DateTime.Now.AddSeconds(1),
System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.Normal,
null);
}
return config;
Using .NET 3.5. Testing on the local machine.
Any idea of what could be causing this?
EDIT: Added the code used to read from the cache