Solution to the problem:
This was a unique and interesting problem, so I will document the cause and solution here as an answer for future search engines.
Something I forgot about in my question was that this cache insert occurred in a service class that implements a singleton pattern.
In a nutshell:
public class Service
{
private static readonly Service _Instance = new Service();
static Service () { }
private Service () { }
public static Service Instance
{
get { return _Instance; }
}
private someObject _data = null;
public someObject Data
{
get
{
if (_data == null)
loadData();
return _data;
}
}
private void loadData()
{
_data = GetFromCache();
if (_data == null)
{
_data = ExpensiveDataSourceGet();
HttpContext.Current.Cache.Insert(etc);
}
}
}
, . , , , , .
Cache.Insert , , , - . , , , "_data" reset null, singleton .
, , , , .
?
HttpContext.Current.Cache.Insert(
"Key",
SomeObject,
new CacheDependency(Server.MapPath("SomeFile.txt")),
DateTime.MaxValue,
TimeSpan.Zero,
CacheItemPriority.High,
delegate(string key, object value, CacheItemRemovedReason reason)
{
_data = null;
}
);
, ... .
? .