Skip to content

Instantly share code, notes, and snippets.

@nrk
Created October 26, 2009 21:45
Show Gist options
  • Select an option

  • Save nrk/219077 to your computer and use it in GitHub Desktop.

Select an option

Save nrk/219077 to your computer and use it in GitHub Desktop.
Pipelining commands in redis-lua
* PONG
* true
* 0
* 10
* 40
* 1
* 40
* {2=40}
require 'luarocks.require'
require 'redis'
require 'base'
local redis = Redis.connect("192.168.1.205", 6379)
-- all the commands inside of a pipeline are sent to the server
-- in one go, thus avoiding chatty sessions with redis.
local replies = redis:pipeline(function()
ping()
flush_database()
exists('counter')
increment_by('counter', 10)
increment_by('counter', 30)
exists('counter')
get('counter')
get_multiple('does_not_exist', 'counter')
end)
for _, reply in pairs(replies) do
print('*', reply)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment