6

I have rocksDB java implementation and I want to possibility of only in-memory storing data without it writing on hdd. I think I can do this using options while creating rocksDB. I tried to make same what is writting here: https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide in section "In-memory database with full functionalities" but I cannot make exactly same because It is about c++ implementation and Java either doesn't have some properties or they are not editable.

Options options = new Options()
options.setCreateIfMissing(true);
BlockBasedTableConfig tableOptions = new BlockBasedTableConfig();
tableOptions.setNoBlockCache(true);
tableOptions.setBlockRestartInterval(4);
options.setTableFormatConfig(tableOptions);
options.setCompressionType(CompressionType.NO_COMPRESSION);
options.setMaxOpenFiles(-1);
try {
    final Path dbPath = getDbPath();
    if (!Files.isSymbolicLink(dbPath.getParent())) {
        Files.createDirectories(dbPath.getParent());
    }
    try {
        database = org.rocksdb.RocksDB.open(options, dbPath.toString());
    } catch (RocksDBException e) {
        logger.error(e.getMessage(), e);
    }

    alive = true;

} catch (IOException ioe) {
    logger.error(ioe.getMessage(), ioe);
}
Ivan
  • 8,508
  • 2
  • 19
  • 30
Gleb
  • 61
  • 4

0 Answers0