【发布时间】:2018-07-02 19:25:40
【问题描述】:
我如何确定这种情况总是正确的: 假设我有 3 个表,其中包含 1000、2000、3000 条记录。 而且我必须将所有记录加载到缓存中,但我想确保在客户端使用此缓存之前所有数据都在缓存中。
注意缓存模式是复制的。
Apache Ignite 有这样的未来吗?
以下是我打算做的事情:
我会将“atomicityMode”设置为“TRANSACTIONAL”
我将为 cacheStoreFactory 创建类
该类包含从 CacheStoreAdapter 扩展而来的 loadCache 方法。
这是伪代码:
public void loadCache(IgniteBiInClosure<K, V> clo, Object... args) {
// Connect the all databases
/*while true:
try(Transaction transaction = Ignition.ignite().transactions().txStart(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE)){
PreparedStatement for all databases such as "select * from persons"
then take the all ResultSet from all databases
then create the corresponding object from the results and put the "clo.apply(objectID, object);"
before transaction.commit()
if there is way, find the total records number from all databases (maybe find before starting try block)
then, again if there is way, compare the cache size and total records
If 2 numbers are equals -> transaction.commmit() & break
else -> continue;
}
*/
}
【问题讨论】:
标签: java apache-spark caching ignite