@nxtedition/rocksdb 13.4.2 → 13.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/binding.cc CHANGED
@@ -922,26 +922,49 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
922
922
  rocksdb::BlockBasedTableOptions tableOptions;
923
923
  tableOptions.decouple_partitioned_filters = true;
924
924
 
925
+ std::shared_ptr<rocksdb::Cache> cache;
925
926
  {
926
927
  uint32_t cacheSize = 8 << 20;
927
928
  double compressedRatio = 0.0;
928
929
 
929
- // Compat
930
930
  NAPI_STATUS_RETURN(GetProperty(env, options, "cacheSize", cacheSize));
931
931
  NAPI_STATUS_RETURN(GetProperty(env, options, "cacheCompressedRatio", compressedRatio));
932
+
933
+ if (cacheSize == 0) {
934
+ cache = nullptr;
935
+ } else if (compressedRatio > 0.0) {
936
+ rocksdb::TieredCacheOptions options;
937
+ options.cache_type = rocksdb::PrimaryCacheType::kCacheTypeHCC;
938
+ options.total_capacity = cacheSize;
939
+ options.compressed_secondary_ratio = compressedRatio;
940
+ cache = rocksdb::NewTieredCache(options);
941
+ } else {
942
+ cache = rocksdb::HyperClockCacheOptions(cacheSize, 0).MakeSharedCache();
943
+ }
944
+ }
945
+
946
+ {
947
+ uint32_t cacheSize = -1;
948
+ double compressedRatio = 0.0;
949
+
950
+ NAPI_STATUS_RETURN(GetProperty(env, options, "cachePrepopulate", tableOptions.prepopulate_block_cache));
932
951
  NAPI_STATUS_RETURN(GetProperty(env, options, "prepopulateBlockCache", tableOptions.prepopulate_block_cache));
933
952
 
934
953
  NAPI_STATUS_RETURN(GetProperty(env, options, "blockCacheSize", cacheSize));
935
954
  NAPI_STATUS_RETURN(GetProperty(env, options, "blockCacheCompressedRatio", compressedRatio));
936
955
  NAPI_STATUS_RETURN(GetProperty(env, options, "blockCachePrepopulate", tableOptions.prepopulate_block_cache));
937
956
 
938
- if (cacheSize == 0) {
939
- tableOptions.no_block_cache = true;
957
+ if (cacheSize == -1) {
958
+ if (cache) {
959
+ tableOptions.block_cache = cache;
960
+ } else {
961
+ tableOptions.no_block_cache = true;
962
+ }
940
963
  } else if (compressedRatio > 0.0) {
941
964
  rocksdb::TieredCacheOptions options;
965
+ options.cache_type = rocksdb::PrimaryCacheType::kCacheTypeHCC;
942
966
  options.total_capacity = cacheSize;
943
967
  options.compressed_secondary_ratio = compressedRatio;
944
- options.comp_cache_opts.compression_type = rocksdb::CompressionType::kZSTD;
945
968
  tableOptions.block_cache = rocksdb::NewTieredCache(options);
946
969
  } else {
947
970
  tableOptions.block_cache = rocksdb::HyperClockCacheOptions(cacheSize, 0).MakeSharedCache();
@@ -952,7 +975,7 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
952
975
  uint32_t cacheSize = -1;
953
976
  double compressedRatio = 0.0;
954
977
 
955
- // Compat
978
+ NAPI_STATUS_RETURN(GetProperty(env, options, "cachePrepopulate", columnOptions.prepopulate_blob_cache));
956
979
  NAPI_STATUS_RETURN(GetProperty(env, options, "prepopulateBlobCache", columnOptions.prepopulate_blob_cache));
957
980
 
958
981
  NAPI_STATUS_RETURN(GetProperty(env, options, "blobCacheSize", cacheSize));
@@ -960,7 +983,7 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
960
983
  NAPI_STATUS_RETURN(GetProperty(env, options, "blobCachePrepopulate", columnOptions.prepopulate_blob_cache));
961
984
 
962
985
  if (cacheSize == -1) {
963
- columnOptions.blob_cache = tableOptions.block_cache;
986
+ columnOptions.blob_cache = cache;
964
987
  } else if (cacheSize == 0) {
965
988
  columnOptions.blob_cache = nullptr;
966
989
  } else if (compressedRatio > 0.0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "13.4.2",
3
+ "version": "13.4.4",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",