Skip to content

Instantly share code, notes, and snippets.

@am97
am97 / reset-rspamd-bayes-data.md
Last active April 30, 2024 13:57
Reset Rspamd Bayes data

Reset Rspamd Bayes data

Backup your Redis data, then run:

redis-cli smembers BAYES_HAM_keys | while read -r PREFIX; do
  if [ -n "$PREFIX" ]; then
    redis-cli --scan --pattern "$PREFIX*" | xargs -r redis-cli unlink
  fi
done
@am97
am97 / README.md
Last active April 30, 2024 13:09
Rspamd efficient learn

Rspamd efficient learn

When learning multiple messages with rspamc learn_spam or rspamc learn_ham, Rspamd may learn more messages than it actually needs. For example:

  • You have 0 messages learned as spam
  • You have 0 messages learned as ham
  • You run rspamc learn_spam some_dir with a dir containing 1000 messages
  • All of the 1000 messages will be learned, leading to ressource waste

Instead, if you learn some ham, then some spam, wait and repeat, then Rspamd won't need to learn all the messages, as some of them will already be classified as spam/ham with the already learned messages.