This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 6a1e23bef feat(storage): allow to enable the blob cache (#3027)
6a1e23bef is described below
commit 6a1e23befe035a022f1a4cf11b019121aa68fb1f
Author: Ryan Liao <[email protected]>
AuthorDate: Tue Jun 17 12:37:44 2025 -0400
feat(storage): allow to enable the blob cache (#3027)
Co-authored-by: hulk <[email protected]>
---
kvrocks.conf | 4 ++++
src/config/config.cc | 1 +
src/config/config.h | 1 +
src/storage/storage.cc | 1 +
4 files changed, 7 insertions(+)
diff --git a/kvrocks.conf b/kvrocks.conf
index a8a0de53d..25172cb88 100644
--- a/kvrocks.conf
+++ b/kvrocks.conf
@@ -320,6 +320,10 @@ max-replication-mb 0
# Default: 0
max-io-mb 0
+# Whether to cache blob files within the block cache.
+# Default: no
+enable-blob-cache no
+
# The maximum allowed space (in GB) that should be used by RocksDB.
# If the total size of the SST files exceeds max_allowed_space, writes to
RocksDB will fail.
# Please see:
https://github.com/facebook/rocksdb/wiki/Managing-Disk-Space-Utilization
diff --git a/src/config/config.cc b/src/config/config.cc
index 52f5266b0..6db8cdfd3 100644
--- a/src/config/config.cc
+++ b/src/config/config.cc
@@ -192,6 +192,7 @@ Config::Config() {
{"log-level", false, new
EnumField<spdlog::level::level_enum>(&log_level, log_levels,
spdlog::level::info)},
{"pidfile", true, new StringField(&pidfile, kDefaultPidfile)},
{"max-io-mb", false, new IntField(&max_io_mb, 0, 0, INT_MAX)},
+ {"enable-blob-cache", true, new YesNoField(&enable_blob_cache, false)},
{"max-bitmap-to-string-mb", false, new
IntField(&max_bitmap_to_string_mb, 16, 0, INT_MAX)},
{"max-db-size", false, new IntField(&max_db_size, 0, 0, INT_MAX)},
{"max-replication-mb", false, new IntField(&max_replication_mb, 0, 0,
INT_MAX)},
diff --git a/src/config/config.h b/src/config/config.h
index 71b2dab85..e97843a20 100644
--- a/src/config/config.h
+++ b/src/config/config.h
@@ -123,6 +123,7 @@ struct Config {
int max_db_size = 0;
int max_replication_mb = 0;
int max_io_mb = 0;
+ bool enable_blob_cache = false;
int max_bitmap_to_string_mb = 16;
bool master_use_repl_port = false;
bool purge_backup_on_fullsync = false;
diff --git a/src/storage/storage.cc b/src/storage/storage.cc
index 3bd8ed29b..47afc5bf2 100644
--- a/src/storage/storage.cc
+++ b/src/storage/storage.cc
@@ -146,6 +146,7 @@ rocksdb::BlockBasedTableOptions Storage::InitTableOptions()
{
void Storage::SetBlobDB(rocksdb::ColumnFamilyOptions *cf_options) {
cf_options->enable_blob_files = config_->rocks_db.enable_blob_files;
+ cf_options->blob_cache = config_->enable_blob_cache ? shared_block_cache_ :
nullptr;
cf_options->min_blob_size = config_->rocks_db.min_blob_size;
cf_options->blob_file_size = config_->rocks_db.blob_file_size;
cf_options->blob_compression_type = config_->rocks_db.compression;