开发者

With AppFabric caching, can you use concurrency methods with the local cache enabled?

开发者 https://www.devze.com 2023-04-03 17:20 出处:网络
I\'m trying to figure out if it\'s possible to use the pessimistic concurrency model and the local cache at the same time.

I'm trying to figure out if it's possible to use the pessimistic concurrency model and the local cache at the same time.

When you've got the local cache enabled, and you use pessimistic concurrency methods like GetAndLock and PutAndUnlock, where is it that the locking/getting/putting is taking place? On the cache cluster, or in the local cache? And if it's happening on the cluster, does it automat开发者_JAVA百科ically synchronize the changes with the local cache?


Yes, you can use local cache and pessimistic concurrency. In fact, you can use either concurrency because, as you hinted at in the question, all the concurrency resolution takes place in the 'master' cache. Which, if you think about it, is the only place it can take place - imagine if you had two server that had locked items in their local cache, that were unlocked at the same time - the 'master' cache wouldn't know which one was the 'true' item to then replicate round the cluster, so all the pessimistic locks/optimistic versioning checks have to happen in the centre.

Once the concurrency resolution (of whichever model) has taken place, the local cache will be re-synchronised, but this depends on how you've configured your local cache. Locally-cached items can either timeout and be refreshed from the master, or the master can issue a notification to local caches when an item is updated. There's some discussion of this on this page, and detail on how you can configure this in your app. or web.config here.

0

精彩评论

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

关注公众号