Drop: support for colddb
This commit is contained in:
parent
e16e72956f
commit
01a13d6b8f
@ -9,21 +9,12 @@ factions.parcels = {}
|
|||||||
factions.players = {}
|
factions.players = {}
|
||||||
factions.player_ips = {}
|
factions.player_ips = {}
|
||||||
|
|
||||||
if factions_config.database == "colddb" then
|
dofile (minetest.get_modpath("fac_database") .. "/storagedb.lua")
|
||||||
-- Create cold databases.
|
factions.root = storagedb.Storagedb("factions")
|
||||||
factions.root = colddb.Colddb(minetest.get_worldpath() .. "/factions")
|
factions.factions = factions.root.sub_database("factions")
|
||||||
factions.factions = factions.root.sub_database("factions")
|
factions.parcels = factions.root.sub_database("parcels")
|
||||||
factions.parcels = factions.root.sub_database("parcels")
|
factions.players = factions.root.sub_database("players")
|
||||||
factions.players = factions.root.sub_database("players")
|
factions.player_ips = factions.root.sub_database("ips")
|
||||||
factions.player_ips = factions.root.sub_database("ips")
|
|
||||||
elseif factions_config.database == "mod_storage" then
|
|
||||||
dofile (minetest.get_modpath("fac_database") .. "/storagedb.lua")
|
|
||||||
factions.root = storagedb.Storagedb("factions")
|
|
||||||
factions.factions = factions.root.sub_database("factions")
|
|
||||||
factions.parcels = factions.root.sub_database("parcels")
|
|
||||||
factions.players = factions.root.sub_database("players")
|
|
||||||
factions.player_ips = factions.root.sub_database("ips")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Memory only storage.
|
-- Memory only storage.
|
||||||
factions.onlineplayers = {}
|
factions.onlineplayers = {}
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
name = fac_database
|
name = fac_database
|
||||||
depends = fac_config
|
depends = fac_config
|
||||||
optional_depends = colddb
|
|
||||||
|
@ -16,51 +16,31 @@ function storagedb.Storagedb(dir)
|
|||||||
setmetatable(mem_pool_del, {__mode = "kv"})
|
setmetatable(mem_pool_del, {__mode = "kv"})
|
||||||
|
|
||||||
local function storekey(key)
|
local function storekey(key)
|
||||||
local list = minetest.deserialize(storage:get_string(directory))
|
local list = deserializer(storage:get_string(directory))
|
||||||
if not list then
|
if not list then
|
||||||
list = {}
|
list = {}
|
||||||
list[key] = key
|
list[key] = key
|
||||||
else
|
else
|
||||||
list[key] = key
|
list[key] = key
|
||||||
end
|
end
|
||||||
storage:set_string(directory, minetest.serialize(list))
|
storage:set_string(directory, serializer(list))
|
||||||
end
|
end
|
||||||
local function removekey(key)
|
local function removekey(key)
|
||||||
local list = minetest.deserialize(storage:get_string(directory))
|
local list = deserializer(storage:get_string(directory))
|
||||||
if not list then
|
if not list then
|
||||||
list = {}
|
list = {}
|
||||||
else
|
else
|
||||||
list[key] = nil
|
list[key] = nil
|
||||||
end
|
end
|
||||||
storage:set_string(directory, minetest.serialize(list))
|
storage:set_string(directory, serializer(list))
|
||||||
end
|
end
|
||||||
local function getkeys()
|
local function getkeys()
|
||||||
local list = minetest.deserialize(storage:get_string(directory))
|
local list = deserializer(storage:get_string(directory))
|
||||||
if not list then
|
if not list then
|
||||||
list = {}
|
list = {}
|
||||||
end
|
end
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
|
|
||||||
self.get_memory_pool = function()
|
|
||||||
return mem_pool
|
|
||||||
end
|
|
||||||
self.set_memory_pool = function(pool)
|
|
||||||
mem_pool = pool
|
|
||||||
end
|
|
||||||
self.add_to_memory_pool = function(value)
|
|
||||||
if value then
|
|
||||||
add_to_mem_pool = value
|
|
||||||
end
|
|
||||||
return add_to_mem_pool
|
|
||||||
end
|
|
||||||
self.get_serializer = function()
|
|
||||||
return serializer, deserializer
|
|
||||||
end
|
|
||||||
self.set_serializer = function(coder, decoder)
|
|
||||||
serializer = coder
|
|
||||||
deserializer = decoder
|
|
||||||
end
|
|
||||||
local function load_into_mem(name, _table)
|
local function load_into_mem(name, _table)
|
||||||
if add_to_mem_pool then
|
if add_to_mem_pool then
|
||||||
mem_pool[name] = {mem = _table}
|
mem_pool[name] = {mem = _table}
|
||||||
@ -79,7 +59,7 @@ function storagedb.Storagedb(dir)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
storekey(name)
|
storekey(name)
|
||||||
storage:set_string(string.format("%s/%s", directory, name), minetest.serialize(_table))
|
storage:set_string(string.format("%s/%s", directory, name), serializer(_table))
|
||||||
end
|
end
|
||||||
local function save_key(name)
|
local function save_key(name)
|
||||||
storage:set_string(string.format("%s/%s", directory, name), "")
|
storage:set_string(string.format("%s/%s", directory, name), "")
|
||||||
@ -91,6 +71,25 @@ function storagedb.Storagedb(dir)
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
self.get_memory_pool = function()
|
||||||
|
return mem_pool
|
||||||
|
end
|
||||||
|
self.set_memory_pool = function(pool)
|
||||||
|
mem_pool = pool
|
||||||
|
end
|
||||||
|
self.add_to_memory_pool = function(value)
|
||||||
|
if value then
|
||||||
|
add_to_mem_pool = value
|
||||||
|
end
|
||||||
|
return add_to_mem_pool
|
||||||
|
end
|
||||||
|
self.get_serializer = function()
|
||||||
|
return serializer, deserializer
|
||||||
|
end
|
||||||
|
self.set_serializer = function(coder, decoder)
|
||||||
|
serializer = coder
|
||||||
|
deserializer = decoder
|
||||||
|
end
|
||||||
self.set_mem = function(name, _table)
|
self.set_mem = function(name, _table)
|
||||||
load_into_mem(name, _table)
|
load_into_mem(name, _table)
|
||||||
mem_pool_del[name] = nil
|
mem_pool_del[name] = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user