Skip to content

Commit e179629

Browse files
committed
fix:block_cache_size
1 parent abfaa02 commit e179629

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/pika_server.cc

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,12 +1479,21 @@ void PikaServer::InitStorageOptions() {
14791479
storage_options_.table_options.pin_l0_filter_and_index_blocks_in_cache =
14801480
g_pika_conf->pin_l0_filter_and_index_blocks_in_cache();
14811481

1482-
if (storage_options_.block_cache_size == 0) {
1483-
storage_options_.table_options.no_block_cache = true;
1484-
} else if (storage_options_.share_block_cache) {
1485-
storage_options_.table_options.block_cache =
1486-
rocksdb::NewLRUCache(storage_options_.block_cache_size, static_cast<int>(g_pika_conf->num_shard_bits()));
1487-
}
1482+
if (storage_options_.block_cache_size == 0) {
1483+
storage_options_.table_options.no_block_cache = true;
1484+
storage_options_.table_options.block_cache.reset();
1485+
} else if (storage_options_.share_block_cache) {
1486+
// 共享模式:直接复用已创建好的全局 cache(PikaServer 成员)
1487+
storage_options_.table_options.no_block_cache = false;
1488+
assert(share_block_cache_ && "shared_block_cache_ must be initialized before InitStorageOptions()");
1489+
storage_options_.table_options.block_cache = shared_block_cache_;
1490+
} else {
1491+
// 非共享模式:为当前 CF/实例单独创建
1492+
storage_options_.table_options.no_block_cache = false;
1493+
storage_options_.table_options.block_cache =
1494+
rocksdb::NewLRUCache(storage_options_.block_cache_size,
1495+
static_cast<int>(g_pika_conf->num_shard_bits()));
1496+
}
14881497
storage_options_.options.rate_limiter =
14891498
std::shared_ptr<rocksdb::RateLimiter>(
14901499
rocksdb::NewGenericRateLimiter(

0 commit comments

Comments
 (0)