Skip to content

Instantly share code, notes, and snippets.

@shirro shirro/gist:952677
Created May 3, 2011

Embed
What would you like to do?
Redis scripting memoize commands
-- Enables calling redis('command',...) as redis.command(...)
if type(redis) == 'function'
then redis = (
function()
local redis_call = redis
local mt = {
__call = function (self, ...)
return redis_call(...)
end,
__index = function (self, key)
local fn = function(...)
return redis_call(key, ...)
end
self[key] = fn
return fn
end
}
return setmetatable({}, mt)
end) ()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.