k = (gchar *)g_ptr_array_index (cbdata->cur_keys, i);
if (k) {
+ const gchar *learned_key = "learns";
+
+ if (cbdata->elt->ctx->new_schema) {
+ if (cbdata->elt->ctx->stcf->is_spam) {
+ learned_key = "learns_spam";
+ }
+ else {
+ learned_key = "learns_ham";
+ }
+ }
+
redisAsyncCommand (cbdata->redis, rspamd_redis_stat_key,
cbdata,
"HLEN %s",
k);
redisAsyncCommand (cbdata->redis, rspamd_redis_stat_learns,
cbdata,
- "HGET %s learns",
- k);
+ "HGET %s %s",
+ k, learned_key);
cbdata->inflight += 2;
}
}
rspamd_fstring_t *query;
struct timeval tv;
gint ret;
+ const gchar *learned_key = "learns";
+
if (tokens == NULL || tokens->len == 0 || rt->redis == NULL) {
return FALSE;
rt->id = id;
+ if (rt->ctx->new_schema) {
+ if (rt->ctx->stcf->is_spam) {
+ learned_key = "learns_spam";
+ }
+ else {
+ learned_key = "learns_ham";
+ }
+ }
+
if (redisAsyncCommand (rt->redis, rspamd_redis_connected, rt, "HGET %s %s",
- rt->redis_object_expanded, "learns") == REDIS_OK) {
+ rt->redis_object_expanded, learned_key) == REDIS_OK) {
rspamd_session_add_event (task->s, rspamd_redis_fin, rt,
rspamd_redis_stat_quark ());
rspamd_token_t *tok;
gint ret;
goffset off;
+ const gchar *learned_key = "learns";
up = rspamd_upstream_get (rt->ctx->write_servers,
RSPAMD_UPSTREAM_MASTER_SLAVE,
rt->selected = up;
+ if (rt->ctx->new_schema) {
+ if (rt->ctx->stcf->is_spam) {
+ learned_key = "learns_spam";
+ }
+ else {
+ learned_key = "learns_ham";
+ }
+ }
+
addr = rspamd_upstream_addr (up);
g_assert (addr != NULL);
"$%d\r\n"
"%s\r\n"
"$6\r\n"
- "learns\r\n"
+ "%s\r\n" /* Learned key */
"$1\r\n"
"1\r\n",
(gint)strlen (rt->redis_object_expanded),
- rt->redis_object_expanded);
+ rt->redis_object_expanded,
+ learned_key);
}
else {
rspamd_printf_fstring (&query, ""
"$%d\r\n"
"%s\r\n"
"$6\r\n"
- "learns\r\n"
+ "%s\r\n" /* Learned key */
"$2\r\n"
"-1\r\n",
(gint)strlen (rt->redis_object_expanded),
- rt->redis_object_expanded);
+ rt->redis_object_expanded,
+ learned_key);
}
ret = redisAsyncFormattedCommand (rt->redis, NULL, NULL,