|
What happens when the database value changes while a request that uses the cached object is in the middle of processing?
For example:
public void MyMethod()
{
string strValue = (string)Cache.Get("StringValue");
if (strValue == null)
{
' assume that "dependency" is a cache file dependency
Cache.Insert("StringValue", "hello", dependency);
'... cache file dependency triggers because the file was modified ...
'Cache("StringValue") is invalidated
Response.Write((string)Cache.Get("StringValue"));
'unexpected results appear
}
else
{
Response.Write(strValue);
}
}
|