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

Method SUnsubscribeChannel

src/server/server.cc:576–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

574}
575
576void Server::SUnsubscribeChannel(const std::string &channel, redis::Connection *conn, uint16_t slot) {
577 assert((config_->cluster_enabled && slot < HASH_SLOTS_SIZE) || slot == 0);
578 std::lock_guard<std::mutex> guard(pubsub_shard_channels_mu_);
579
580 auto iter = pubsub_shard_channels_[slot].find(channel);
581 if (iter == pubsub_shard_channels_[slot].end()) {
582 return;
583 }
584
585 for (const auto &conn_ctx : iter->second) {
586 if (conn->GetFD() == conn_ctx.fd && conn->Owner() == conn_ctx.owner) {
587 iter->second.remove(conn_ctx);
588 if (iter->second.empty()) {
589 pubsub_shard_channels_[slot].erase(iter);
590 }
591 break;
592 }
593 }
594}
595
596void Server::GetSChannelsByPattern(const std::string &pattern, std::vector<std::string> *channels) {
597 std::lock_guard<std::mutex> guard(pubsub_shard_channels_mu_);

Callers 1

ExecuteMethod · 0.45

Calls 3

endMethod · 0.80
GetFDMethod · 0.80
OwnerMethod · 0.80

Tested by

no test coverage detected