Add: new functions

This commit is contained in:
Coder12a 2019-03-15 21:14:30 -05:00
parent 1b98c81e55
commit 45c925efaf

View File

@ -10,18 +10,48 @@ function colddb.Colddb(dir)
local directory = dir
local mem_pool = {}
local mem_pool_del = {}
local indexes_pool = {}
local iterate_queue = {}
local add_to_mem_pool = true
local async = extended_api.Async()
local path_count = {}
async.priority(150, 250)
-- make tables weak so the garbage-collector will remove unused data
setmetatable(mem_pool, {__mode = "kv"})
setmetatable(mem_pool_del, {__mode = "kv"})
setmetatable(indexes_pool, {__mode = "kv"})
self.get_directory = function()
return directory
end
self.set_directory = function(new_directory)
directory = new_directory
if not minetest.mkdir(directory) then
error(string.format("%s is not a directory.", dir))
end
end
self.get_memory_pool = function()
return mem_pool
end
self.set_memory_pool = function(pool)
mem_pool = pool
end
self.get_async = function()
return async
end
self.set_async = function(new_async)
async = new_async
end
self.add_to_memory_pool = function(value)
if value then
add_to_mem_pool = value
end
return add_to_mem_pool
end
local function file_exists(name)
local f = io.open(string.format("%s%s.cold", directory, name), "r")