Created
June 14, 2011 09:11
-
-
Save nrk/1024554 to your computer and use it in GitHub Desktop.
Define AlchemyDB commands with redis-lua
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
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