Skip to content

Instantly share code, notes, and snippets.

@nrk
Created June 14, 2011 09:11
Show Gist options
  • Save nrk/1024554 to your computer and use it in GitHub Desktop.
Save nrk/1024554 to your computer and use it in GitHub Desktop.
Define AlchemyDB commands with redis-lua
require 'redis'
Redis.define_command('create_table', {
request = function(client, command, ...)
local args, arguments = {...}, {}
if #args ~= 2 then
print ('Usage: create_table tablename column_definitions');
return false;
end
table.insert(arguments, 'TABLE');
table.insert(arguments, args[1]);
table.insert(arguments, '(' .. args[2] .. ')');
client.requests.multibulk(client, command, arguments)
end
})
local redis = Redis.connect()
-- ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment