| 2182 | } |
| 2183 | |
| 2184 | void Server::WatchKey(redis::Connection *conn, const std::vector<std::string> &keys) { |
| 2185 | std::unique_lock lock(watched_key_mutex_); |
| 2186 | |
| 2187 | for (const auto &key : keys) { |
| 2188 | if (auto iter = watched_key_map_.find(key); iter != watched_key_map_.end()) { |
| 2189 | iter->second.emplace(conn); |
| 2190 | } else { |
| 2191 | watched_key_map_.emplace(key, std::set<redis::Connection *>{conn}); |
| 2192 | } |
| 2193 | |
| 2194 | conn->watched_keys.insert(key); |
| 2195 | } |
| 2196 | |
| 2197 | watched_key_size_ = watched_key_map_.size(); |
| 2198 | } |
| 2199 | |
| 2200 | bool Server::IsWatchedKeysModified(redis::Connection *conn) { return conn->watched_keys_modified; } |
| 2201 | |