簡體   English   中英

Apache Ignite緩存-從數據庫獲取所有數據-

[英]Apache Ignite Cache - Gets all data from database -

我如何確定這種情況始終為真:假設我有3個表,其中包含1000、2000、3000個記錄。 而且我必須將所有記錄都加載到緩存中,但是在客戶端使用此緩存之前,我想確保所有數據都在緩存中。

請注意,復制了緩存模式。

Apache Ignite有這個未來嗎?

這是我計划要做的事情:

我將“ atomicityMode”設置為“ TRANSACTIONAL”

我將為cacheStoreFactory創建類

此類包含從CacheStoreAdapter擴展的loadCache方法。

這是pseducode:

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;
        }

     */
}

您可以使用分布式數據結構來表示某些操作已完成。 例如:

https://apacheignite.readme.io/docs/countdownlatch

https://apacheignite.readme.io/docs/distributed-semaphore

https://apacheignite.readme.io/docs/atomic-types

同樣,您可以檢查緩存的大小或將消息從一個節點發送到另一個節點,如下所示:

https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/messaging/MessagingExample.java

但是,除非您將數據加載到事務中,否則其他節點將無法讀取它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM