MCPcopy Create free account
hub / github.com/apache/brpc / Get

Method Get

example/redis_c++/redis_server.cpp:76–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 }
75
76 bool Get(const std::string& db_name, const std::string& key, std::string* value) {
77 int slot = butil::crc32c::Value(key.c_str(), key.size()) % kHashSlotNum;
78 _mutex[slot].lock();
79 auto& kv = _db_map[db_name];
80 auto it = kv[slot].find(key);
81 if (it == kv[slot].end()) {
82 _mutex[slot].unlock();
83 return false;
84 }
85 *value = it->second;
86 _mutex[slot].unlock();
87 return true;
88 }
89
90private:
91 const static int kHashSlotNum = 32;

Callers 2

RunMethod · 0.45
senderFunction · 0.45

Calls 7

ValueFunction · 0.50
c_strMethod · 0.45
sizeMethod · 0.45
lockMethod · 0.45
findMethod · 0.45
endMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected