| 930 | } |
| 931 | |
| 932 | bool CouchbaseOperations::CouchbaseRequest::deleteRequest( |
| 933 | const butil::StringPiece& key, std::string collection_name, |
| 934 | brpc::Channel* channel, const std::string& server, const std::string& bucket) { |
| 935 | DEBUG_PRINT("deleteRequest called with key: " |
| 936 | << key << ", collection_name: " << collection_name |
| 937 | << ", server: " << server << ", bucket: " << bucket); |
| 938 | uint8_t coll_id = 0; // default collection ID |
| 939 | if (collection_name != "_default") { |
| 940 | // check if the local cache is empty or not. |
| 941 | if (local_collection_manifest_cache->empty()) { |
| 942 | DEBUG_PRINT("Local collection manifest cache is empty in deleteRequest"); |
| 943 | // if local cache is empty, goto global cache or fetch from server |
| 944 | if (!getCachedOrFetchCollectionId( |
| 945 | collection_name, &coll_id, metadata_tracking, channel, server, |
| 946 | bucket, local_collection_manifest_cache)) { |
| 947 | DEBUG_PRINT( |
| 948 | "Failed to get collection id from global cache or server in " |
| 949 | "deleteRequest"); |
| 950 | return false; |
| 951 | } |
| 952 | } |
| 953 | // check if the collection id is available in the local cache |
| 954 | else if (!getLocalCachedCollectionId(bucket, "_default", collection_name, |
| 955 | &coll_id)) { |
| 956 | DEBUG_PRINT("Collection id not found in local cache in deleteRequest"); |
| 957 | // if not check in the global cache or fetch from server |
| 958 | if (!getCachedOrFetchCollectionId( |
| 959 | collection_name, &coll_id, metadata_tracking, channel, server, |
| 960 | bucket, local_collection_manifest_cache)) { |
| 961 | DEBUG_PRINT( |
| 962 | "Failed to get collection id from global cache or server in " |
| 963 | "deleteRequest"); |
| 964 | return false; |
| 965 | } |
| 966 | } |
| 967 | } |
| 968 | DEBUG_PRINT("deleteRequest using coll_id: " << (int)coll_id); |
| 969 | return getOrDelete(policy::CB_BINARY_DELETE, key, coll_id); |
| 970 | } |
| 971 | |
| 972 | struct FlushHeaderWithExtras { |
| 973 | policy::CouchbaseRequestHeader header; |