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

Method clear

imperative/src/impl/persistent_cache.cpp:95–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 }
94
95 std::optional<size_t> clear() override {
96 long long cursor = 0;
97 size_t nr_deleted = 0;
98 std::string pattern = m_prefix + "*";
99 do {
100 auto reply = m_client.scan(cursor, pattern).share();
101 sync();
102 auto keys = reply.get().as_array();
103 std::vector<std::string> string_keys;
104 for (auto&& key : keys[1].as_array()) {
105 string_keys.push_back(key.as_string());
106 }
107 m_client.del(string_keys);
108 nr_deleted += string_keys.size();
109 cursor = std::stoll(keys[0].as_string());
110 } while (cursor != 0);
111 return nr_deleted;
112 }
113
114private:
115 std::shared_ptr<mgb::PersistentCache> m_local;

Callers

nothing calls this directly

Calls 5

syncFunction · 0.85
delMethod · 0.80
getMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected