set and save: Memory
This commit is contained in:
parent
ea0fceac5e
commit
33f1f5411b
46
colddb.lua
46
colddb.lua
|
@ -361,7 +361,7 @@ function colddb.Colddb(dir)
|
|||
return nil
|
||||
end
|
||||
|
||||
self.append_entry_file = function(name, key, tag_name)
|
||||
self.append_entry_file = function(name, key, op, tag_name)
|
||||
local t = ""
|
||||
if tag_name then
|
||||
t = self.get_tag(tag_name)
|
||||
|
@ -392,10 +392,18 @@ function colddb.Colddb(dir)
|
|||
end
|
||||
indexes_pool[cs].needs_flushing = true
|
||||
local c = 0
|
||||
for i in pairs(key) do
|
||||
fl:seek("end")
|
||||
fl:write(string.format("\n%s", i))
|
||||
c = c + 1
|
||||
if op and op == "key" then
|
||||
for i in pairs(key) do
|
||||
fl:seek("end")
|
||||
fl:write(string.format("\n%s", i))
|
||||
c = c + 1
|
||||
end
|
||||
elseif not op or op == "value" then
|
||||
for i, j in pairs(key) do
|
||||
fl:seek("end")
|
||||
fl:write(string.format("\n%s", j))
|
||||
c = c + 1
|
||||
end
|
||||
end
|
||||
fl:seek("set")
|
||||
local count = tonumber(fl:read("*l"))
|
||||
|
@ -489,6 +497,34 @@ function colddb.Colddb(dir)
|
|||
table.insert(iterate_queue[cs], _table)
|
||||
end
|
||||
end
|
||||
|
||||
self.set_mem = function(name, _table, tag_name)
|
||||
local t = ""
|
||||
if tag_name then
|
||||
t = self.get_tag(tag_name)
|
||||
end
|
||||
load_into_mem(name, _table, tag_name)
|
||||
local cs = string.format("%s%s", t, name)
|
||||
mem_pool_del[cs] = nil
|
||||
end
|
||||
|
||||
self.save_mem = function(name, tag_name)
|
||||
local t = ""
|
||||
|
||||
if tag_name then
|
||||
t = self.get_tag(tag_name)
|
||||
end
|
||||
|
||||
local cs = string.format("%s%s", t, name)
|
||||
|
||||
async.queue_task(function()
|
||||
if mem_pool[cs] ~= nil then
|
||||
save_table(name, mem_pool[cs].mem, tag_name)
|
||||
end
|
||||
end)
|
||||
|
||||
mem_pool_del[cs] = nil
|
||||
end
|
||||
|
||||
self.set = function(name, _table, tag_name)
|
||||
local t = ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user