MCPcopy Create free account
hub / github.com/apache/kvrocks / UnsubscribeChannel

Method UnsubscribeChannel

src/server/server.cc:492–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492void Server::UnsubscribeChannel(const std::string &channel, redis::Connection *conn) {
493 std::lock_guard<std::mutex> guard(pubsub_channels_mu_);
494
495 auto iter = pubsub_channels_.find(channel);
496 if (iter == pubsub_channels_.end()) {
497 return;
498 }
499
500 for (const auto &conn_ctx : iter->second) {
501 if (conn->GetFD() == conn_ctx.fd && conn->Owner() == conn_ctx.owner) {
502 iter->second.remove(conn_ctx);
503 if (iter->second.empty()) {
504 pubsub_channels_.erase(iter);
505 }
506 break;
507 }
508 }
509}
510
511void Server::GetChannelsByPattern(const std::string &pattern, std::vector<std::string> *channels) {
512 std::lock_guard<std::mutex> guard(pubsub_channels_mu_);

Callers 1

ExecuteMethod · 0.45

Calls 3

endMethod · 0.80
GetFDMethod · 0.80
OwnerMethod · 0.80

Tested by

no test coverage detected