Skip to content

Instantly share code, notes, and snippets.

@micha
Created December 21, 2016 00:24
Show Gist options
  • Save micha/1e4fd4ee945f24b710f9c441047b0262 to your computer and use it in GitHub Desktop.
Save micha/1e4fd4ee945f24b710f9c441047b0262 to your computer and use it in GitHub Desktop.
local last_balanced = "lastBalanced"
local orphans_key = "orphanAds"
local last_balanced_ttl = 60 * 20
for i = 1, #ARGV do
local ad_id = ARGV[i]
local ad_key = last_balanced .. ":" .. ad_id
if redis.call("EXISTS", ad_key) ~= 1 then
redis.call("SADD", orphans_key, ad_id)
redis.call("SETEX", ad_key, last_balanced_ttl, 1)
end
end
return {ok="OK"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment