在缓存事务中加入 Infinispan 缓存存储?

Enlisting a Infinispan Cache Store in a Cache Transaction?

我正在通过 Wildfly 8.2 子系统使用 Infinispan 6.0.2。我已经配置了一个事务缓存,它使用基于字符串的 JDBC 缓存存储来持久保存 infinispan 缓存中的内容。

我担心的是,在阅读 Infinispan documentation 中的以下内容后,当 putting/updating/removing 同一事务中的多个条目进入缓存时,缓存和缓存存储可能会变得不同步由于缓存中的事务 committing/rolling-back 但缓存存储中只有部分 succeeding/failing。

4.5. Cache Loaders and transactional caches When a cache is transactional and a cache loader is present, the cache loader won’t be enlisted in the transaction in which the cache is part. That means that it is possible to have inconsistencies at cache loader level: the transaction to succeed applying the in-memory state but (partially) fail applying the changes to the store. Manual recovery would not work with caches stores.

如果上面的陈述也指写入存储,是否仅指从缓存存储加载,请有人澄清一下。

如果写入缓存存储时也是这种情况,是否有任何建议strategies/solutions以确保缓存和缓存存储保持同步?

对我来说,这背后的驱动因素是我正在使用 Infinispan 进行业务关键数据的直写和溢出,并且需要确信缓存存储正确地表示数据的状态。

我也在 Infinispan Forums

上问过这个问题

非常感谢。

它也适用于写入,写入存储失败不会影响事务的其余部分。

原因是实际持久性 API 不是事务性的(编辑:Infinispan 的新版本也支持事务性持久性)。因此,对于两阶段提交(在第一阶段 - 准备 - 获取所有锁,在第二阶段 - 提交 - 执行写入),对存储的写入在第二阶段执行。因此,失败无法回滚不同节点上的更改。

尽管 Infinispan 试图接近强一致性 内存数据库 ,但它仍然是一个 缓存 给出的保证。如果你对设计局限性更感兴趣(其中一些也是理论局限性),我推荐reading Infinispan wiki