]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Do not stress redis with KEYS command (#791)
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 2 Aug 2016 15:09:42 +0000 (16:09 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 2 Aug 2016 15:10:43 +0000 (16:10 +0100)
Issue: #791
Reported by: @wociscz

src/libstat/backends/redis_backend.c

index a935359bd287ca097dfee1f8a8849bdf2c77bffc..83517ba64643a911103c53e1194ca48dc090d6ca 100644 (file)
@@ -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";
        }