通过 AppFabric 缓存,您可以在启用本地缓存的情况下使用并发方法吗?

发布于 2024-12-04 06:13:05 字数 145 浏览 0 评论 0原文

我试图弄清楚是否可以同时使用悲观并发模型和本地缓存。

当您启用本地缓存并使用 GetAndLock 和 PutAndUnlock 等悲观并发方法时,锁定/获取/放置发生在哪里?在缓存集群上,还是在本地缓存中?如果发生在集群上,它是否会自动将更改与本地缓存同步?

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 automatically synchronize the changes with the local cache?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城仅有旧梦在 2024-12-11 06:13:05

是的,您可以使用本地缓存和悲观并发。事实上,您可以使用任一并发,因为正如您在问题中暗示的那样,所有并发解析都发生在“主”缓存中。如果您考虑一下,这是唯一可以发生的地方 - 想象一下,如果您有两台服务器在本地缓存中锁定了项目,并且同时解锁了 - “主”缓存将不知道哪个服务器其中一个是要在集群中复制的“真实”项,因此所有悲观锁/乐观版本控制检查都必须在中心进行。

一旦发生并发解析(无论哪种模型),本地缓存将重新同步,但这取决于您如何配置本地缓存。本地缓存的项目可以超时并从主服务器刷新,或者主服务器可以在项目更新时向本地缓存发出通知。 此页面上对此进行了一些讨论,并详细介绍了如何操作在您的应用程序中配置它。或 web.config 此处

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文