3

We have a very simple AppFabric setup where there are two clients -- lets call them Server A and Server B. Server A is also the lead cache host, and both Server A and B have a local cache enabled. We'd like to be able to make an update to an item from server B and have that change propagate to the local cache of Server A within 30 seconds (for example).

As I understand it, there appears to be two different ways of getting changes propagated to the client:

  1. Set a timeout on the client cache to evict items every X seconds. On next request for the item it will get the item from the host cache since the local cache doesn't have the item
  2. Enable notifications and effectively subscribe to get updates from the cache host

If my requirement is to get updates to all clients within 30 seconds then setting a timeout of less than 30 seconds on the local cache appears to be the only choice if going with option #1 above. Due to the size of the cache, this would be inefficient to evict all of the cache (99.99% of which probably hasn't changed in the last 30 seconds).

I think what we need to implement is option #2 above, but I'm not sure I understand how this works. I've read all of the msdn documentation (http://msdn.microsoft.com/en-us/library/ee808091.aspx) and have looked at some examples but it is still unclear to me whether it is really necessary to write custom code or if this is only if you want to do extra handling.

So my question is: is it necessary to add code to your existing application if want to have updates propagated to all local caches via notifications, or is the callback feature just an bonus way of adding extra handling or code if a notification is pushed down? Can I just enable Notifications and set the appropriate polling interval at the client and things will just work?

It seems like the default behavior (when Notifications are enabled) should be to pull down fresh items automatically at each polling interval.

4

1 回答 1

0

我进行了一些测试,很高兴地说您不需要编写任何代码来确保所有客户端保持同步。如果您将以下内容设置为集群配置的子元素:

在客户端配置中,您需要在元素上设置 sync="NotificationBased"。

客户端配置中的元素将告诉客户端它应该多久检查一次服务器上的新通知。在这种情况下,客户端将每 15 秒检查一次通知并下拉任何已更改的项目。

我猜你可以添加到你的应用程序的回调逻辑只是为了以防你想添加你自己的特殊逻辑(比如每次缓存中的项目发生变化时给总统发电子邮件)。

于 2013-07-25T15:48:44.000 回答