From: Vsevolod Stakhov Date: Tue, 26 Jan 2016 13:16:42 +0000 (+0000) Subject: Use pipelined HINCRBY X-Git-Tag: 1.1.2~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5a2a0d438a9c4848d6a443c2bfc269a37c6f02c;p=thirdparty%2Frspamd.git Use pipelined HINCRBY --- diff --git a/src/rspamadm/stat_convert.lua b/src/rspamadm/stat_convert.lua index c9192ff01c..d33a228667 100644 --- a/src/rspamadm/stat_convert.lua +++ b/src/rspamadm/stat_convert.lua @@ -4,26 +4,25 @@ local _ = require "fun" local function send_redis(server, symbol, tokens) local ret = true - local args = {} - + local conn = redis.connect_sync({ + host = server, + }) + + if not conn then + print('Cannot connect to ' .. server) + return false + end + _.each(function(t) - if not args[t[3]] then - args[t[3]] = {symbol .. t[3]} - end - table.insert(args[t[3]], t[1]) - table.insert(args[t[3]], t[2]) - end, tokens) - - _.each(function(k, argv) - if not redis.make_request_sync({ - host = server, - cmd = 'HMSET', - args = argv - }) then + if not conn:add_cmd('HINCRBY', {symbol .. t[3], t[1], t[2]}) then ret = false end - end, args) + end, tokens) + if ret then + ret = conn:exec() + end + return ret end