add readonly option
This commit is contained in:
parent
2e858e6b9a
commit
22ab21a5ef
|
@ -101,6 +101,7 @@ template bailOnErrors {.dirty.} =
|
|||
|
||||
proc init*(rocks: var RocksDBInstance,
|
||||
dbPath, dbBackupPath: string,
|
||||
readOnly = false,
|
||||
cpus = countProcessors(),
|
||||
createIfMissing = true): RocksDBResult[void] =
|
||||
rocks.options = rocksdb_options_create()
|
||||
|
@ -115,6 +116,9 @@ proc init*(rocks: var RocksDBInstance,
|
|||
rocksdb_options_set_create_if_missing(rocks.options, uint8(createIfMissing))
|
||||
|
||||
var errors: cstring
|
||||
if readOnly:
|
||||
rocks.db = rocksdb_open_for_read_only(rocks.options, dbPath, 0'u8, errors.addr)
|
||||
else:
|
||||
rocks.db = rocksdb_open(rocks.options, dbPath, errors.addr)
|
||||
bailOnErrors()
|
||||
rocks.backupEngine = rocksdb_backup_engine_open(rocks.options,
|
||||
|
|
Loading…
Reference in New Issue