MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / get

Method get

imperative/src/impl/persistent_cache.cpp:60–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 void flush() override {}
59
60 mgb::Maybe<Blob> get(const std::string& category, const Blob& key) override {
61 MGB_LOCK_GUARD(m_mtx);
62 auto mem_result = m_local->get(category, key);
63 if (mem_result.valid()) {
64 return mem_result;
65 }
66 std::string key_str(static_cast<const char*>(key.ptr), key.size);
67 std::string redis_key_str;
68 encode(category + '@' + key_str, redis_key_str, 24);
69 auto result = m_client.get(m_prefix + redis_key_str);
70 sync();
71 auto content = result.get();
72 if (content.is_null()) {
73 return None;
74 }
75 std::string decode_content;
76 mgb_assert(content.is_string());
77 decode(content.as_string(), decode_content);
78 m_local->put(category, key, {decode_content.data(), decode_content.length()});
79 return m_local->get(category, key);
80 }
81
82 void put(const std::string& category, const Blob& key, const Blob& value) override {
83 MGB_LOCK_GUARD(m_mtx);

Callers 15

setup_algoFunction · 0.45
asMethod · 0.45
get_static_infer_valueFunction · 0.45
insert_oprMethod · 0.45
as_tensorMethod · 0.45
connectMethod · 0.45
clearMethod · 0.45
getMethod · 0.45
DnnOprCallerMethod · 0.45
exec_fastrunMethod · 0.45
get_eventMethod · 0.45

Calls 6

encodeFunction · 0.85
syncFunction · 0.85
decodeFunction · 0.85
validMethod · 0.45
putMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected