void McRequest::Keys::update(folly::StringPiece key) { keyWithoutRoute = key; if (!key.empty()) { if (*key.begin() == '/') { size_t pos = 1; for (int i = 0; i < 2; ++i) { pos = key.find('/', pos); if (pos == std::string::npos) { break; } ++pos; } if (pos != std::string::npos) { keyWithoutRoute.advance(pos); routingPrefix.reset(key.begin(), pos); } } } routingKey = keyWithoutRoute; size_t pos = keyWithoutRoute.find("|#|"); if (pos != std::string::npos) { routingKey.reset(keyWithoutRoute.begin(), pos); } routingKeyHash = getMemcacheKeyHashValue(routingKey); }
uint32_t Keys::routingKeyHash() const { if (routingKeyHash_ == 0) { const_cast<uint32_t&>(routingKeyHash_) = getMemcacheKeyHashValue(routingKey_); } return routingKeyHash_; }