From: Vsevolod Stakhov Date: Tue, 2 Aug 2016 15:09:42 +0000 (+0100) Subject: [Fix] Do not stress redis with KEYS command (#791) X-Git-Tag: 1.3.2~76 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d24212c0110df08fd3c85e4e63ce9684306657f6;p=rspamd.git [Fix] Do not stress redis with KEYS command (#791) Issue: #791 Reported by: @wociscz --- diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index a935359bd..83517ba64 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -661,7 +661,7 @@ rspamd_redis_async_stat_cb (struct rspamd_stat_async_elt *elt, gpointer d) /* Get keys in redis that match our symbol */ rspamd_redis_maybe_auth (ctx, cbdata->redis); redisAsyncCommand (cbdata->redis, rspamd_redis_stat_keys, cbdata, - "KEYS %s*", + "SMEMBERS %s_keys", ctx->stcf->symbol); } @@ -1252,6 +1252,12 @@ rspamd_redis_learn_tokens (struct rspamd_task *task, GPtrArray *tokens, redisLibeventAttach (rt->redis, task->ev_base); rspamd_redis_maybe_auth (rt->ctx, rt->redis); + /* + * Add the current key to the set of learned keys + */ + redisAsyncCommand (rt->redis, NULL, NULL, "SADD %s_keys %s", + rt->stcf->symbol, rt->redis_object_expanded); + if (rt->stcf->clcf->flags & RSPAMD_FLAG_CLASSIFIER_INTEGER) { redis_cmd = "HINCRBY"; }