Go to file
Coder12a 5a9a9975a9 Remove: .cold file ext 2019-10-15 11:14:31 -05:00
LICENSE Re-license: mod under MIT 2019-05-16 20:07:27 -05:00
README.md Remove: .cold file ext 2019-10-15 11:14:31 -05:00
colddb.lua Remove: .cold file ext 2019-10-15 11:14:31 -05:00
init.lua Move: desc and depends into conf file 2019-05-13 14:32:42 -05:00
mod.conf Move: desc and depends into conf file 2019-05-13 14:32:42 -05:00

README.md

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.

.cold file ext was removed.

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.