smcculloch posted on February 26, 2006 11:37

Late last week I fixed a particular interesting issue (for News Articles) that is only exposed under heavy loads.
It seems that I wasn't alone however, the pattern is commonly used in core code, and goes something like this:-
If (DataCache.GetCache("object") Is Nothing)
Dim obj = code for loading config from files
DataCache.SetCache("object", obj)
End If
Return DataCache.GetCache("object")
When a more efficient approach should be:-
Dim obj = DataCache.GetCache("object")
If obj Is Nothing
obj = code for loading config from files
DataCache.SetCache("object", obj)
End If
Return obj
You can find out more about the issue here. Kudos to james3838 from the DNN forums for picking it up. It should significantly reduce any exceptions appearing in sites with significant load.