<commit_before>local sqlite3 = require "rspamd_sqlite3"
local redis = require "rspamd_redis"
local _ = require "fun"

local function send_redis(server, symbol, tokens)
  local ret = true
  local args = {}
  
  _.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
      ret = false
    end
  end, args)
  
  return ret<commit_msg>Use pipelined HINCRBY<commit_after>local sqlite3 = require "rspamd_sqlite3"
local redis = require "rspamd_redis"
local _ = require "fun"

local function send_redis(server, symbol, tokens)
  local ret = true
  local conn = redis.connect_sync({
    host = server,
  })

  if not conn then
    print('Cannot connect to ' .. server)
    return false
  end

  _.each(function(t)
    if not conn:add_cmd('HINCRBY', {symbol .. t[3], t[1], t[2]}) then
      ret = false
    end
  end, tokens)
  
  if ret then
    ret = conn:exec()
  end

  return ret
{'fraction_non_alphanumeric': 0.12357581069237511, 'fraction_numerical': 0.012269938650306749, 'mean_word_length': 2.8066666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7461312', 'n_tokens_mistral': 416, 'n_tokens_neox': 414, 'n_words': 113}