Last active
August 29, 2015 14:07
-
-
Save matej21/e16a2846ea61e9413ffb to your computer and use it in GitHub Desktop.
Redis script overujici invalidace zaznamu
This file contains 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
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