0

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

当我从我的缓存集群中添加、删除、更新或删除一个项目时,我想通过我的 c# 代码发送一个通知,说明这种情况已经发生。这可能吗?如果可以,它是如何实现的?

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

4

1 回答 1

0

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.

于 2012-02-14T12:06:44.467 回答