Skip to content

Instantly share code, notes, and snippets.

@dartov
Created September 19, 2012 13:48
Show Gist options
  • Save dartov/3749780 to your computer and use it in GitHub Desktop.
Save dartov/3749780 to your computer and use it in GitHub Desktop.
Redis Lua "where" function
local keys = redis.call('hgetall',KEYS[1])
local i = ARGV[1]
local key
local value
for k,v in ipairs(keys) do
if k % 2 == 0 then
value = v
else
key = v
end
if value == i then
return key
end
-- redis.log(redis.LOG_WARNING, k,v)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment