diff --git a/src/pika_server.cc b/src/pika_server.cc index b205f3e34b..86b2171f93 100644 --- a/src/pika_server.cc +++ b/src/pika_server.cc @@ -1478,13 +1478,24 @@ void PikaServer::InitStorageOptions() { storage_options_.table_options.pin_l0_filter_and_index_blocks_in_cache = g_pika_conf->pin_l0_filter_and_index_blocks_in_cache(); + if (storage_options_.block_cache_size == 0) { + // 禁用 block_cache + storage_options_.table_options.no_block_cache = true; + storage_options_.table_options.block_cache.reset(); + } else if (storage_options_.share_block_cache) { + if (!g_pika_conf->share_block_cache()) { + assert(false && "shared_block_cache_ must be initialized before InitStorageOptions()"); + } - if (storage_options_.block_cache_size == 0) { - storage_options_.table_options.no_block_cache = true; - } else if (storage_options_.share_block_cache) { - storage_options_.table_options.block_cache = - rocksdb::NewLRUCache(storage_options_.block_cache_size, static_cast(g_pika_conf->num_shard_bits())); - } + storage_options_.table_options.no_block_cache = false; + + storage_options_.table_options.block_cache = 0; + } else { + storage_options_.table_options.no_block_cache = false; + storage_options_.table_options.block_cache = + rocksdb::NewLRUCache(storage_options_.block_cache_size, + static_cast(g_pika_conf->num_shard_bits())); + } storage_options_.options.rate_limiter = std::shared_ptr( rocksdb::NewGenericRateLimiter(