You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a Lua wrapper library for TidesDB therefore first you need
a copy of TidesDB
git clone https://github.com/tidesdb/tidesdb.git
Build it and install
cd tidesdb
cmake -DTIDESDB_WITH_SANITIZER=OFF -S . -B build && make -C build/
sudo cmake --install build
Build Lua library
git clone https://github.com/tidesdb/tidesdb-lua.git
cd tidesdb-lua
cmake -S . -B build && make -C build/
As a result libtidesdb_lua.so library is built
Basic operations
-- Open lua wrapper librarylocallib=require("libtidesdb_lua")
-- Open a TidesDB databaselocalcode, message, db=lib.open("my_db")
--assert error codes for failuresassert(code==0, message)
-- Create a column familycode, message=db:create_column_family(
"my_column_family",
1024*1024*64, -- Flush threshold (64MB)12, -- Max level skip list, if using hash table is irrelevant0.24, -- Probability skip list, if using hash table is irrelevanttrue, -- Enable compressiondb.COMPRESS_SNAPPY, -- Compression algorithm can be NO_COMPRESSION, COMPRESS_SNAPPY, COMPRESS_LZ4, COMPRESS_ZSTDtrue, -- Enable bloom filter
)
-- Put key-value pair into the databasecode, message=db:put("my_column_family", "key", "value", 3600)
-- Get the value for the keycode, message, value=db:get("my_column_family", "key")
-- Delete the key-value pairdb:delete("my_column_family", "key")
-- Create a cursor for iterating over key-value pairscode, message, cursor=db:cursor_init("my_column_family")
assert(code==0, message)
-- Move cursor to next key-value paircode, message=cursor:next()
assert(code==0, message)
-- Get current key-value paircode, message, value=cursor:get()
assert(code==0, message)
-- Move cursor to previous key-value paircode, message=cursor:prev()
assert(code==0, message)
-- Free cursor when donecode, message=cursor:free()
assert(code==0, message)
--- Close the databaselib.close(db)