MCPcopy Create free account
hub / github.com/apache/brpc / addRequest

Method addRequest

src/brpc/couchbase.cpp:1337–1379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1335}
1336
1337bool CouchbaseOperations::CouchbaseRequest::addRequest(
1338 const butil::StringPiece& key, const butil::StringPiece& value,
1339 uint32_t flags, uint32_t exptime, uint64_t cas_value,
1340 std::string collection_name, brpc::Channel* channel, const std::string& server,
1341 const std::string& bucket) {
1342 DEBUG_PRINT("addRequest called with key: "
1343 << key << ", value: " << value
1344 << ", collection_name: " << collection_name
1345 << ", server: " << server << ", bucket: " << bucket);
1346 uint8_t coll_id = 0; // default collection ID
1347 if (collection_name != "_default") {
1348 // check if the local cache is empty or not.
1349 if (local_collection_manifest_cache->empty()) {
1350 DEBUG_PRINT("Local collection manifest cache is empty in addRequest");
1351 // if local cache is empty, goto global cache or fetch from server
1352 if (!getCachedOrFetchCollectionId(
1353 collection_name, &coll_id, metadata_tracking, channel, server,
1354 bucket, local_collection_manifest_cache)) {
1355 DEBUG_PRINT(
1356 "Failed to get collection id from global cache or server in "
1357 "addRequest");
1358 return false;
1359 }
1360 }
1361 // check if the collection id is available in the local cache
1362 else if (!getLocalCachedCollectionId(bucket, "_default", collection_name,
1363 &coll_id)) {
1364 DEBUG_PRINT("Collection id not found in local cache in addRequest");
1365 // if not check in the global cache or fetch from server
1366 if (!getCachedOrFetchCollectionId(
1367 collection_name, &coll_id, metadata_tracking, channel, server,
1368 bucket, local_collection_manifest_cache)) {
1369 DEBUG_PRINT(
1370 "Failed to get collection id from global cache or server in "
1371 "addRequest");
1372 return false;
1373 }
1374 }
1375 }
1376 DEBUG_PRINT("addRequest using coll_id: " << (int)coll_id);
1377 return store(policy::CB_BINARY_ADD, key, value, flags, exptime, cas_value,
1378 coll_id);
1379}
1380
1381bool CouchbaseOperations::CouchbaseRequest::appendRequest(
1382 const butil::StringPiece& key, const butil::StringPiece& value,

Callers 4

mainFunction · 0.80
TEST_FFunction · 0.80
sendRequestFunction · 0.80
pipelineRequestMethod · 0.80

Calls 1

emptyMethod · 0.45

Tested by 1

TEST_FFunction · 0.64