I am using Cache
in a web service method like this:
var pblDataList = (List)HttpContext.Current.Cache.Get(\"pblDataList\");
if (pblDa
I believe the Add
should be thread-safe - i.e. it won't error if Add
gets called twice with the same key, but obviously the query might execute twice.
Another question, however, is is the data thread-safe. There is no guarantee that each List
is isolated - it depends on the cache-provider. The in-memory cache provider stores the objects directly, so there is a risk of collisions if any of the threads edit the data (add/remove/swap items in the list, or change properties of one of the items). However, with a serializing provider you should be fine. Of course, this then demands that blabla
is serializable...