diff --git a/CMakeLists.txt b/CMakeLists.txt index a1956503d..a95d61ee8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ if(CCACHE_FOUND) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) endif(CCACHE_FOUND) +option(WHITH_CACH "build with cach" ON) option(WITH_JEMALLOC "build with JeMalloc" OFF) option(WITH_LIBURING "build with liburing" ON) option(WITH_SNAPPY "build with SNAPPY" OFF) @@ -1012,11 +1013,17 @@ endif() add_library(${ROCKSDB_STATIC_LIB} STATIC ${SOURCES} ${BUILD_VERSION_CC}) target_link_libraries(${ROCKSDB_STATIC_LIB} PRIVATE ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) +if (WHITH_CACH) + target_compile_definitions(${ROCKSDB_STATIC_LIB} PRIVATE ROCKSDB_CACH_ENABLE=1) +endif() if(ROCKSDB_BUILD_SHARED) add_library(${ROCKSDB_SHARED_LIB} SHARED ${SOURCES} ${BUILD_VERSION_CC}) target_link_libraries(${ROCKSDB_SHARED_LIB} PRIVATE ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) + if (WHITH_CACH) + target_compile_definitions(${ROCKSDB_SHARED_LIB} PRIVATE ROCKSDB_CACH_ENABLE=1) + endif() if(WIN32) set_target_properties(${ROCKSDB_SHARED_LIB} PROPERTIES diff --git a/db/version_set.cc b/db/version_set.cc index 6efc6ffbd..aea82ef15 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -2315,6 +2315,7 @@ async_result Version::AsyncGet(const ReadOptions& read_options, if (LIKELY(value != nullptr)) { value->PinSelf(); } + co_return Status::OK(); } else { if (key_exists != nullptr) { *key_exists = false; @@ -2322,6 +2323,9 @@ async_result Version::AsyncGet(const ReadOptions& read_options, *status = Status::NotFound(); // Use an empty error message for speed co_return Status::NotFound(); } + + *status = Status::OK(); + co_return Status::OK(); } void Version::MultiGet(const ReadOptions& read_options, MultiGetRange* range, diff --git a/include/rocksdb/async_result.h b/include/rocksdb/async_result.h index 301c92b85..452cdc512 100644 --- a/include/rocksdb/async_result.h +++ b/include/rocksdb/async_result.h @@ -52,6 +52,10 @@ struct async_result { void unhandled_exception() { std::exit(1); } + void return_value(std::nullptr_t) + { + } + void return_value(Status result) { ret_back_promise->result_ = result; ret_back_promise->result_set_ = true; diff --git a/table/block_based/block_based_table_reader_impl.h b/table/block_based/block_based_table_reader_impl.h index 49eb1eb2b..89b0245c3 100644 --- a/table/block_based/block_based_table_reader_impl.h +++ b/table/block_based/block_based_table_reader_impl.h @@ -150,11 +150,15 @@ async_result BlockBasedTable::AsyncNewDataBlockIterator( ? *uncompression_dict.GetValue() : UncompressionDict::GetEmptyDict(); + bool use_cache = false; +#ifdef ROCKSDB_CACH_ENABLE + use_cache = true; +#endif CachableEntry block; auto result = AsyncRetrieveBlock(prefetch_buffer, ro, handle, dict, &block, block_type, get_context, lookup_context, for_compaction, - /* use_cache */ true, /* wait_for_cache */ true); + use_cache, /* wait_for_cache */ true); co_await result; s = result.result();