I've noticed in quite a few places that the root cause for exceptions is the pattern I see DataCache.GetCache() used.
The patten that I see is:
If (DataCache.GetCache("object") Is Nothing)
Dim obj = code for loading config from files
DataCache.SetCache("object", obj)
End If
Return DataCache.GetCache("object")
The problem I'm seeing is there is a time window between the SetCache and the final return that can result in the cache being thrown out, especially when multithreaded operations are happening.
Wouldn't the following pattern make more sense?
Dim obj = DataCache.GetCache("object")
If obj Is Nothing
obj = code for loading config from files
DataCache.SetCache("object", obj)
End If
Return obj