views:

12

answers:

0

In my project I am using SharedCache as a distributed caching mechanism. There are multiple instances of a service deployed in webfarm which accesses this cached data. The data which is cached is transient and can have updates. I would like to know if there is any way we can synchronize the access to the data between two or more services?

To give you an example here is a scenario, imagine there are 2 instances of a service running. Both the instances are accessing the shared cache. If one service picks up some data from the cache for processing I would want the other service to not pick the same information. For that I need to update the cache with some status saying unavailable. But while I am updating the status, it might happen that the second service might also pick the same data.

Shared cache doccumentation thread safety suggests that the data is globaly available and is not thread safe. Is there a way to make it thread safe without changing the source code of SharedCache?