| 890 | } |
| 891 | |
| 892 | bool CouchbaseOperations::CouchbaseRequest::getRequest( |
| 893 | const butil::StringPiece& key, std::string collection_name, |
| 894 | brpc::Channel* channel, const std::string& server, const std::string& bucket) { |
| 895 | DEBUG_PRINT("getRequest called with key: " |
| 896 | << key << ", collection_name: " << collection_name |
| 897 | << ", server: " << server << ", bucket: " << bucket); |
| 898 | uint8_t coll_id = 0; // default collection ID |
| 899 | if (collection_name != "_default") { |
| 900 | // check if the local cache is empty or not. |
| 901 | if (local_collection_manifest_cache->empty()) { |
| 902 | DEBUG_PRINT("Local collection manifest cache is empty in getRequest"); |
| 903 | // if local cache is empty, goto global cache or fetch from server |
| 904 | if (!getCachedOrFetchCollectionId( |
| 905 | collection_name, &coll_id, metadata_tracking, channel, server, |
| 906 | bucket, local_collection_manifest_cache)) { |
| 907 | DEBUG_PRINT( |
| 908 | "Failed to get collection id from global cache or server in " |
| 909 | "getRequest"); |
| 910 | return false; |
| 911 | } |
| 912 | } |
| 913 | // check if the collection id is available in the local cache |
| 914 | else if (!getLocalCachedCollectionId(bucket, "_default", collection_name, |
| 915 | &coll_id)) { |
| 916 | DEBUG_PRINT("Collection id not found in local cache in getRequest"); |
| 917 | // if not check in the global cache or fetch from server |
| 918 | if (!getCachedOrFetchCollectionId( |
| 919 | collection_name, &coll_id, metadata_tracking, channel, server, |
| 920 | bucket, local_collection_manifest_cache)) { |
| 921 | DEBUG_PRINT( |
| 922 | "Failed to get collection id from global cache or server in " |
| 923 | "getRequest"); |
| 924 | return false; |
| 925 | } |
| 926 | } |
| 927 | } |
| 928 | DEBUG_PRINT("getRequest using coll_id: " << (int)coll_id); |
| 929 | return getOrDelete(policy::CB_BINARY_GET, key, coll_id); |
| 930 | } |
| 931 | |
| 932 | bool CouchbaseOperations::CouchbaseRequest::deleteRequest( |
| 933 | const butil::StringPiece& key, std::string collection_name, |