Last active
July 11, 2018 09:37
-
-
Save echohes/fffb3d9e99504e8d510647f51ef61f9b to your computer and use it in GitHub Desktop.
Tarantool-Queue, adding tasks to the queue based on the time from 9 to 21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_timing_cache(num,tz,cth,ctm) | |
-- Time Calculate delay and ttl queues options | |
-- num - number, tz - timezone(utc), cth - current time hour, ctm - current time mintute | |
num_time = tz + cth | |
if num_time < 9 then | |
delay = tonumber(((9 - num_time) * 60 * 60) -(ctm * 60)) | |
ttl = 43100 | |
return {delay,ttl} | |
elseif num_time >= 9 and num_time < 21 then | |
delay = 2 | |
ttl = tonumber(((21 - num_time) * 60 * 60) - (ctm * 60)) | |
return {delay,ttl} | |
elseif num_time >= 21 and num_time < 24 then | |
delay = tonumber(((9 + (24 - num_time)) * 60 * 60) - (ctm * 60)) | |
ttl = 43100 | |
return {delay,ttl} | |
elseif num_time >= 24 then | |
ttl = 43100 | |
delay = tonumber(((9 - (num_time - 24)) * 60 * 60) - (ctm * 60)) | |
return {delay,ttl} | |
else | |
return nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment