Hear us Roar
Article:
 |
|
Using SQL Cache Dependency
|
| Subject: |
|
Cache and Timing |
| Date: |
|
2007-08-29 09:27:03 |
| From: |
|
Skyfish
|
|
|
|
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);
}
}
|
|
| |