Lua binding for RocksDB
- Install RocksDB (make shared_lib, make static_lib), download from: https://github.com/facebook/rocksdb
- Update the Makefile if needed to point at the correct include/lib paths
local rocksdb = require("rocksdb")
local options = rocksdb.options({
create_if_missing = true
})
local db = rocksdb.open(options, "/tmp/test.rocksdb")
local writeoptions = rocksdb.writeoptions()
local readoptions = rocksdb.readoptions()
db:put(writeoptions, "key", "value")
print(db:get(readoptions, "key"))
db:close()
Creates an options object, the options are passed as a table. Currently only basic types (bool, int, uint64) types are supported.
Creates a readoptions object.
Create a writeoptions object.
Create a restoreoptions object.
- table options map, supported:
- keep_log_files - number of log files to keep
- options - object (created using rocksdb.options())
- db_path - string. path
- returns rocksdb object (referenced below as db)
Execute a put command, key-value (both of string type).
- writeoptions - write options object (created using rocksdb.writeoptions())
- key - string
- value - string
Gets a value from the DB.
- readoptions - read options object (created using rocksdb.readoptions())
- key - string
Executes write operation on a batch.
- writeoptions - created using rocksdb.writeoptions()
- writebatch - created using rocksdb.writebatch()
Returns an iterator object.
Closes the instance (it doesn't destroy the DB!)
Creates a backup engine object.
- options options object (created using rocksdb.options())
- backup_path - string - backup path
- returns backup_engine object
Creates a back from db.
- db db object (rocksdb.open())
- returns true on success, error on failure
Purge number of old backups.
Returns the number of the available backups.
Returns info of a backup at index (note indices start at 1, to keep with Lua 1-based array).
- returns table
keys
- id
- timestamp
- size
- number_files
Restores DB from the latest backup.
- db_path (string)
- wal_dir (string)
- restoreoptions (created using rocksdb.restoreoptions()) Returns an error on failure
Close/free the backup_engine instance
Creates a writebatch instance.
Puts a key with its value into the batch (both are strings).
Returns the count of key-values pairs in the batch.
Clears the writebatch.
Frees the writebatch instance.
Returns true if the iterator is valid, false otherwise.
Seek to first/last iterm.
Seek specific key.
Move to next/prev item.
Returns string key/value.
Returns string error message of the iterator.
Frees the iterator instance.