29 #ifndef GPGFRONTEND_CACHEMANAGER_H
30 #define GPGFRONTEND_CACHEMANAGER_H
34 #include "core/GpgFunctionObject.h"
38 template <
typename Key,
typename Value>
41 using MapType = std::map<Key, Value>;
42 using IteratorType =
typename MapType::iterator;
44 void insert(
const Key& key,
const Value& value) {
45 std::unique_lock lock(mutex_);
49 std::optional<Value> get(
const Key& key) {
50 std::shared_lock lock(mutex_);
51 auto it = map_.find(key);
52 if (it != map_.end()) {
58 bool exists(
const Key& key) {
59 std::shared_lock lock(mutex_);
60 return map_.count(key) > 0;
63 IteratorType begin() {
return map_mirror_.begin(); }
65 IteratorType end() {
return map_mirror_.end(); }
68 std::shared_lock lock(mutex_);
76 mutable std::shared_mutex mutex_;
86 void SaveCache(std::string key,
const nlohmann::json& value,
89 nlohmann::json LoadCache(std::string key);
91 nlohmann::json LoadCache(std::string key, nlohmann::json default_value);
94 std::string get_data_object_key(std::string key);
96 nlohmann::json load_cache_storage(std::string key,
97 nlohmann::json default_value);
99 void load_all_cache_storage();
101 void flush_cache_storage();
103 void register_cache_key(std::string key);
106 nlohmann::json key_storage_;
108 const std::string drk_key_ =
"__cache_manage_data_register_key_list";
Definition: CacheManager.h:81
Definition: GpgFunctionObject.h:150
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:251
Definition: CacheManager.h:39
Definition: CoreCommonUtil.cpp:31