通知本地缓存缓存集群中的变化

发布于 2025-01-05 12:01:18 字数 206 浏览 3 评论 0原文

我在我的 C# 应用程序中使用 appfabric 缓存。我已经启用了本地缓存。

当我从缓存集群中添加、删除、更新或删除项目时,我想通过我的 C# 代码发送已发生此类情况的通知。这可能吗?如果可能的话,如何实现?

我正在考虑在应用程序的 web.config 上进行设置,以轮询查找缓存集群的更新,但我担心这可能会出现性能问题,因此我想在我的代码中包含通知的触发器。

I am using appfabric caching in my c# application. I have enabled local cache.

When I add, remove, update or delete an item from my cache cluster I would like to send a notification that such has occurred via my c# code. Is this possible and if so how is it achieved?

I was considering setting it up on the web.config of my application to poll looking for updates to the cache cluster but I am concerned that this may have performance issues therefore I would like to include the trigger of the notification in my code.

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

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

发布评论

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

评论(1

月下客 2025-01-12 12:01:18

如果您尝试启用本地缓存中的无效/更新缓存项目的通知,那么我有一些好消息给您:您不必编写任何 C# 代码来实现此目的,AppFabric 会为您做到这一点。请参阅此 MSDN 页面上的第二段。

您可以在 web 中配置本地缓存以接收来自群集的通知。或 app.config代码中当您实例化DataCacheFactory。您还需要在创建缓存时启用缓存本身的通知,例如

New-Cache -CacheName MyCache -NotificationsEnabled true

本地缓存将轮询集群以获取通知;默认轮询间隔为 300 秒,但如果您愿意,您可以在配置中调整此间隔,具体取决于您认为缓存数据的易失性。

If you're trying to enable notifications for invalidating/updating cached items in the local cache, then I have some good news for you: you don't have to write any C# code to achieve this, AppFabric will do it for you. See the second paragraph on this MSDN page.

You can configure the local cache to receive notifications from the cluster, either in your web. or app.config or in code when you instantiate a DataCacheFactory. You'll also need to enable notifications on the cache itself when you create it e.g.

New-Cache -CacheName MyCache -NotificationsEnabled true

The local cache will then poll the cluster for notifications; the default poll interval is 300 seconds but you can tune this in your config if you wish, depending on how volatile you believe your cached data to be.

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