| 95 | } |
| 96 | |
| 97 | WasmResult SharedData::remove(std::string_view vm_id, std::string_view key, uint32_t cas, |
| 98 | std::pair<std::string, uint32_t> *result) { |
| 99 | std::lock_guard<std::mutex> lock(mutex_); |
| 100 | std::unordered_map<std::string, std::pair<std::string, uint32_t>> *map; |
| 101 | auto map_it = data_.find(std::string(vm_id)); |
| 102 | if (map_it == data_.end()) { |
| 103 | return WasmResult::NotFound; |
| 104 | } |
| 105 | map = &map_it->second; |
| 106 | auto it = map->find(std::string(key)); |
| 107 | if (it != map->end()) { |
| 108 | if (cas != 0U && cas != it->second.second) { |
| 109 | return WasmResult::CasMismatch; |
| 110 | } |
| 111 | if (result != nullptr) { |
| 112 | *result = it->second; |
| 113 | } |
| 114 | map->erase(it); |
| 115 | return WasmResult::Ok; |
| 116 | } |
| 117 | return WasmResult::NotFound; |
| 118 | } |
| 119 | |
| 120 | } // namespace proxy_wasm |
no test coverage detected