milo: refresh interval

This commit is contained in:
kepler155c
2018-11-13 14:32:37 -05:00
parent 986fe160c7
commit 2af29c5d93
4 changed files with 32 additions and 6 deletions

View File

@@ -8,9 +8,22 @@ local RefreshTask = {
}
function RefreshTask:cycle(context)
if os.clock() - context.storage.lastRefresh > 60 then
context.storage:refresh()
local now = os.clock()
for node, adapter in context.storage:onlineAdapters() do
if node.refreshInterval then
if not adapter.lastRefresh or adapter.lastRefresh + node.refreshInterval < now then
_G._debug('REFRESHER: ' .. adapter.name)
context.storage.dirty = true
adapter.dirty = true
adapter.lastRefresh = now
end
end
end
-- if os.clock() - context.storage.lastRefresh > 60 then
-- context.storage:refresh()
-- end
end
Milo:registerTask(RefreshTask)