| 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 | |
| 90 | private: |
| 91 | const static int kHashSlotNum = 32; |