Minetest mod - based on https://github.com/uleelx/FlatDB
Go to file
2019-05-23 10:27:02 -05:00
colddb.lua Merge: down later 2019-05-23 10:27:02 -05:00
init.lua Move: desc and depends into conf file 2019-05-13 14:32:42 -05:00
LICENSE Re-license: mod under MIT 2019-05-16 20:07:27 -05:00
mod.conf Move: desc and depends into conf file 2019-05-13 14:32:42 -05:00
README.md Update: license notice in readme 2019-05-20 12:31:55 -05:00

ColdDB

ColdDB is a minetest mod that implements a serverless, asynchronous, NoSQL database engine.
It provides a key or key-value based storage system using plain Lua tables.

Usage

Copy both colddb.lua and async files to your minetest mod or game. Copy the code from colddb's init file to your mods init file
Write this code in your lua file.

  1. create a directory and link it as a database.
coldbase = colddb.Colddb("mydb")
  1. store key item(this key has no value)
coldbase.set_key("MyKey")
  1. store key-value item
coldbase.set("MyKeyAndValue", "Hello world")
  1. retrieve items (get_key's callback(arg) will return true, false, or nil)
coldbase.get("MyKeyAndValue", nil, function(arg)
	if arg then
		minetest.log(string.format("value:%s", arg))
	end
end)
coldbase.get_key("MyKey", nil, function(arg)
	if arg then
		minetest.log("Found key")
	else
		minetest.log("Key not found")
	end
end)
  1. delete key(file) this function works on both keys and key-value keys.
coldbase.remove("MyKeyAndValue")
  1. if add_to_mem_pool is true(true by default). keys are stored in a weak lua table(memory) it will be removed by the gc if its not in-use. Storing data in memory is to prevent the database from constantly loading up data from files.
coldbase.add_to_mem_pool = true

License

ColdDB is distributed under the MIT license.