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

Method upsertRequest

src/brpc/couchbase.cpp:1274–1316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1272}
1273
1274bool CouchbaseOperations::CouchbaseRequest::upsertRequest(
1275 const butil::StringPiece& key, const butil::StringPiece& value,
1276 uint32_t flags, uint32_t exptime, uint64_t cas_value,
1277 std::string collection_name, brpc::Channel* channel, const std::string& server,
1278 const std::string& bucket) {
1279 DEBUG_PRINT("upsertRequest called with key: "
1280 << key << ", value: " << value
1281 << ", collection_name: " << collection_name
1282 << ", server: " << server << ", bucket: " << bucket);
1283 uint8_t coll_id = 0; // default collection ID
1284 if (collection_name != "_default") {
1285 // check if the local cache is empty or not.
1286 if (local_collection_manifest_cache->empty()) {
1287 DEBUG_PRINT("Local collection manifest cache is empty in upsertRequest");
1288 // if local cache is empty, goto global cache or fetch from server
1289 if (!getCachedOrFetchCollectionId(
1290 collection_name, &coll_id, metadata_tracking, channel, server,
1291 bucket, local_collection_manifest_cache)) {
1292 DEBUG_PRINT(
1293 "Failed to get collection id from global cache or server in "
1294 "upsertRequest");
1295 return false;
1296 }
1297 }
1298 // check if the collection id is available in the local cache
1299 else if (!getLocalCachedCollectionId(bucket, "_default", collection_name,
1300 &coll_id)) {
1301 DEBUG_PRINT("Collection id not found in local cache in upsertRequest");
1302 // if not check in the global cache or fetch from server
1303 if (!getCachedOrFetchCollectionId(
1304 collection_name, &coll_id, metadata_tracking, channel, server,
1305 bucket, local_collection_manifest_cache)) {
1306 DEBUG_PRINT(
1307 "Failed to get collection id from global cache or server in "
1308 "upsertRequest");
1309 return false;
1310 }
1311 }
1312 }
1313 DEBUG_PRINT("upsertRequest using coll_id: " << (int)coll_id);
1314 return store(policy::CB_BINARY_SET, key, value, flags, exptime, cas_value,
1315 coll_id);
1316}
1317
1318bool CouchbaseOperations::CouchbaseRequest::getCollectionManifest() {
1319 const policy::CouchbaseRequestHeader header = {

Callers 3

TEST_FFunction · 0.80
sendRequestFunction · 0.80
pipelineRequestMethod · 0.80

Calls 1

emptyMethod · 0.45

Tested by 1

TEST_FFunction · 0.64