aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-02 16:09:42 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-02 16:10:43 +0100
commitd24212c0110df08fd3c85e4e63ce9684306657f6 (patch)
tree9c88ff6930213424b5c935af7bf440ee2b92edc2 /src/libstat
parent95f240a6ae7eef18ff56eae8ee240afeb3d9076a (diff)
downloadrspamd-d24212c0110df08fd3c85e4e63ce9684306657f6.tar.gz
rspamd-d24212c0110df08fd3c85e4e63ce9684306657f6.zip
[Fix] Do not stress redis with KEYS command (#791)
Issue: #791 Reported by: @wociscz
Diffstat (limited to 'src/libstat')
-rw-r--r--src/libstat/backends/redis_backend.c8
1 files changed, 7 insertions, 1 deletions
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";
}