diff options
author | Saturneric <[email protected]> | 2023-07-13 07:39:20 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2023-07-13 07:39:20 +0000 |
commit | 82dbb2626ed3ffdc5819e2c0ad040b07982fb94a (patch) | |
tree | ae3b10727f172e1e6030fb2bcfc7dda65ef8f83f | |
parent | feat: support marking a key as favourite (diff) | |
download | GpgFrontend-82dbb2626ed3ffdc5819e2c0ad040b07982fb94a.tar.gz GpgFrontend-82dbb2626ed3ffdc5819e2c0ad040b07982fb94a.zip |
feat: support instant flush when save cache
-rw-r--r-- | src/core/function/CacheManager.cpp | 7 | ||||
-rw-r--r-- | src/core/function/CacheManager.h | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/core/function/CacheManager.cpp b/src/core/function/CacheManager.cpp index c5270999..b24a8050 100644 --- a/src/core/function/CacheManager.cpp +++ b/src/core/function/CacheManager.cpp @@ -45,7 +45,8 @@ GpgFrontend::CacheManager::CacheManager(int channel) } void GpgFrontend::CacheManager::SaveCache(std::string key, - const nlohmann::json& value) { + const nlohmann::json& value, + bool flush) { auto data_object_key = get_data_object_key(key); cache_storage_.insert(key, value); @@ -54,6 +55,10 @@ void GpgFrontend::CacheManager::SaveCache(std::string key, SPDLOG_DEBUG("register new key of cache", key); key_storage_.push_back(key); } + + if (flush) { + flush_cache_storage(); + } } nlohmann::json GpgFrontend::CacheManager::LoadCache(std::string key) { diff --git a/src/core/function/CacheManager.h b/src/core/function/CacheManager.h index 7a175586..8234de2a 100644 --- a/src/core/function/CacheManager.h +++ b/src/core/function/CacheManager.h @@ -83,7 +83,8 @@ class GPGFRONTEND_CORE_EXPORT CacheManager public: CacheManager(int channel = SingletonFunctionObject::GetDefaultChannel()); - void SaveCache(std::string key, const nlohmann::json& value); + void SaveCache(std::string key, const nlohmann::json& value, + bool flush = false); nlohmann::json LoadCache(std::string key); |