diff --git a/colddb.lua b/colddb.lua index 29f40df..d30be21 100644 --- a/colddb.lua +++ b/colddb.lua @@ -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")