From a49529ad9b52efe5ea6df9834eb143cfd0d0a9c5 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sat, 13 May 2023 15:11:32 +0100 Subject: [PATCH] Cache updating moved back to existing threads when processing or importing a transaction, to remove chances of queued updates being lost. The dedicated cache manager thread is now used for metadata updates only. If metadata ever goes missing from the db, it would be straightforward to have a background thread that corrects any discrepancies between the filesystem and the db. Not adding that until it is needed. --- .../transaction/ArbitraryTransaction.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/qortal/transaction/ArbitraryTransaction.java b/src/main/java/org/qortal/transaction/ArbitraryTransaction.java index ab5adc76..a189adf2 100644 --- a/src/main/java/org/qortal/transaction/ArbitraryTransaction.java +++ b/src/main/java/org/qortal/transaction/ArbitraryTransaction.java @@ -250,17 +250,8 @@ public class ArbitraryTransaction extends Transaction { // We may need to move files from the misc_ folder ArbitraryTransactionUtils.checkAndRelocateMiscFiles(arbitraryTransactionData); - // If the data is local, we need to perform a few actions - if (isDataLocal()) { - - // We have the data for this transaction, so invalidate the cache - if (arbitraryTransactionData.getName() != null) { - ArbitraryDataManager.getInstance().invalidateCache(arbitraryTransactionData); - } - } - - // Add to queue for cache updates - ArbitraryDataCacheManager.getInstance().addToUpdateQueue(arbitraryTransactionData); + // Update caches + updateCaches(); } @Override @@ -296,8 +287,9 @@ public class ArbitraryTransaction extends Transaction { } } - // Add to queue for cache updates - ArbitraryDataCacheManager.getInstance().addToUpdateQueue(arbitraryTransactionData); + // Add/update arbitrary resource caches + this.updateArbitraryResourceCache(); + this.updateArbitraryMetadataCache(); } catch (Exception e) { // Log and ignore all exceptions. The cache is updated from other places too, and can be rebuilt if needed.