mirror of
https://github.com/kikito/cron.lua.git
synced 2024-12-19 18:34:20 +00:00
made scopecache weak. Fixes #7
This commit is contained in:
parent
4ea9f257a8
commit
e4e341832d
4
cron.lua
4
cron.lua
@ -109,7 +109,7 @@ local function storeScopeInCache(scope)
|
|||||||
local node = scopeCacheRoot
|
local node = scopeCacheRoot
|
||||||
for i=1, scope.len do
|
for i=1, scope.len do
|
||||||
local tag = scope.tags[i]
|
local tag = scope.tags[i]
|
||||||
node.children[tag] = node.children[tag] or { children={} }
|
node.children[tag] = node.children[tag] or { children=setmetatable({},{__mode='k'}) }
|
||||||
node = node.children[tag]
|
node = node.children[tag]
|
||||||
end
|
end
|
||||||
node.scope = scope
|
node.scope = scope
|
||||||
@ -165,7 +165,7 @@ end
|
|||||||
function cron.reset()
|
function cron.reset()
|
||||||
entries = {}
|
entries = {}
|
||||||
taggedEntries = setmetatable({}, {__mode='k'})
|
taggedEntries = setmetatable({}, {__mode='k'})
|
||||||
scopeCacheRoot = { children = {}}
|
scopeCacheRoot = { children = setmetatable({}, {__mode='k'}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- tagged functions
|
-- tagged functions
|
||||||
|
@ -159,8 +159,5 @@ describe( 'cron', function()
|
|||||||
assert_equal(counter, 4)
|
assert_equal(counter, 4)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('caches scopes', function()
|
|
||||||
assert_equal(cron.tagged('hello', 'world'), cron.tagged('hello', 'world'))
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user