Skip to content

Instantly share code, notes, and snippets.

@matej21
Last active August 29, 2015 14:07
Show Gist options
  • Save matej21/e16a2846ea61e9413ffb to your computer and use it in GitHub Desktop.
Save matej21/e16a2846ea61e9413ffb to your computer and use it in GitHub Desktop.
Redis script overujici invalidace zaznamu
local key = KEYS[1]
local val = redis.call("get", key)
if val == nil then
return nil
end
local tags = redis.call('sMembers', "Nette.Journal:" .. key .. ":tags")
local expirations = redis.call("hMGet", "invalidations", unpack(tags))
local added = nil
for i, expiration in pairs(expirations) do
if expiration ~= false then
if added == nil then
added = redis.call("hGet", "added", key)
end
if added < expiration then
return nil
end
end
end
return val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment