开发者

Synchronize access to keys stored in distributed cache (SharedCache)

开发者 https://www.devze.com 2023-01-09 21:32 出处:网络
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 tran

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, imag开发者_开发知识库ine 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?


As mentioned by myself there is a lock within sharedcache code and its syncronized. hence voting for closing of this question.

0

精彩评论

暂无评论...
验证码 换一张
取 消