Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class KeyValueStorageRocksDB implements KeyValueStorage {

private final WriteOptions optionSync;
private final WriteOptions optionDontSync;
private final Cache cache;

private final ReadOptions optionCache;
private final ReadOptions optionDontCache;
Expand Down Expand Up @@ -139,7 +140,7 @@ public KeyValueStorageRocksDB(String basePath, String subPath, DbConfigType dbCo
options.setTargetFileSizeBase(sstSizeMB * 1024 * 1024);
options.setDeleteObsoleteFilesPeriodMicros(TimeUnit.HOURS.toMicros(1));

final Cache cache = new LRUCache(blockCacheSize);
this.cache = new LRUCache(blockCacheSize);
BlockBasedTableConfig tableOptions = new BlockBasedTableConfig();
tableOptions.setBlockSize(blockSize);
tableOptions.setBlockCache(cache);
Expand All @@ -154,6 +155,8 @@ public KeyValueStorageRocksDB(String basePath, String subPath, DbConfigType dbCo
options.setLevelCompactionDynamicLevelBytes(true);

options.setTableFormatConfig(tableOptions);
} else {
this.cache = null;
}

// Configure file path
Expand Down Expand Up @@ -210,6 +213,9 @@ public KeyValueStorageRocksDB(String basePath, String subPath, DbConfigType dbCo
@Override
public void close() throws IOException {
db.close();
if (cache != null) {
cache.close();
}
optionSync.close();
optionDontSync.close();
optionCache.close();
Expand Down