Reputation: 9712
Can I synclock effectively on an object stored in the cache?
Like:
SyncLock System.Web.HttpContext.Current.Cache("Some Object")
'do some stuff that is threadsafe on this cached object'
End SyncLock
Will this stop another thread from modifying that cached object?
Upvotes: 0
Views: 809
Reputation: 4384
For the standard cache, yes. But it won't stop another thread replacing the object in the cache - you'll need to use a separate sync object for that. And if you happen to be using a distributed cache (e.g. Velocity) then it's not necessarily reliable either.
Upvotes: 1