首页 > 解决方案 > 查询远程过滤器内的不同缓存以进行连续查询

问题描述

我有一个 Ignite 连续查询的用例,我想在其中设置远程过滤器,以便它针对同一节点上的另一个缓存进行评估。例如:

我开始对 Person 缓存进行连续查询,并在另一个缓存(“City”)上使用远程过滤条件,以便 P.city 存在于 City 缓存中。

在我的用例中,我控制城市缓存,这意味着用户动态设置他/她感兴趣的城市。城市缓存总体上相对较小(~400)。我应该提到过滤器必须检查缓存而不是使用分布式数据结构,因为我需要保持对订阅的计数。

基本上,我想了解这种方法对性能的影响。

任何帮助,将不胜感激!

标签: ignite

解决方案


这取决于你在那里做出什么样的逻辑。如果您阅读文档,您将看到:

Sets optional key-value filter. This filter is called before entry is sent to the master node.
WARNING: all operations that involve any kind of JVM-local or distributed locking (e.g., synchronization or transactional cache operations), should be executed asynchronously without blocking the thread that called the filter. Otherwise, you can get deadlocks.

这意味着您应该避免在那里进行阻塞或长时间运行的操作。但是,文档还为您提供了有关如何执行此操作的答案:

If remote filter are annotated with IgniteAsyncCallback then it is executed in async callback pool (see IgniteConfiguration.getAsyncCallbackPoolSize()) that allow to perform a cache operations.

因此,为避免可能出现的性能问题,您应该使用IgniteAsyncCallback


推荐阅读