0

My C++ app is using RocksDB to store in-memory key-value sets.

At some points, I want my app to be able to keep the DB values until its next run. Meaning, the program will shut down, start again and read the same values from the DB as it had before it shut down.

What would be the quickest and simplest way to achieve this?

I found the following article for backup & restore routine - https://github.com/facebook/rocksdb/wiki/How-to-backup-RocksDB%3F, but maybe its an overkill?

Mugen
  • 8,301
  • 10
  • 62
  • 140
  • Looks simple, why do you think its an overkill ? I think it's kind of simple steps (but I guess it could be lot more simpler). – Arunmu Jun 13 '16 at 13:46
  • It's simple, but do I really need a full backup in order to keep my DB state? I would assume backup is a more extensive and basic operation – Mugen Jun 14 '16 at 06:37
  • I am not completely sure but I guess you should be able to persist the data per transaction synchronously or asynchronously. – Arunmu Jun 14 '16 at 08:00

2 Answers2

1

rocksdb already provide some ways to persist in-memory RocksDB database. u can see this link to conigure your rocksdb. http://rocksdb.org/blog/245/how-to-persist-in-memory-rocksdb-database/

yinqiwen
  • 604
  • 6
  • 6
  • To my understanding, this article is about backing up (in fact, adding fault tolerance to) in-memory DB, which is never supposed to be stored on persistent media in the first place. What do you think? – Mugen Jun 14 '16 at 05:23
  • 1
    The data file is saved in tmpfs, which means the data file would be there until current os restart. – yinqiwen Jun 14 '16 at 08:09
1

Adding to what yinqiwen said, RocksDB was not meant to be just an in memory data store. It works really well with a variety of storage types. And it is especially good in terms of performance when it comes to flash storage. You may use a variety of RocksDB Options to experiment with what configuration is best to use for your workload, but for most cases, even with the default settings for the persistent storage types, rocks db should work just fine.

Prateek Jain
  • 136
  • 5