Mail::...sStore(3pm)

๐Ÿ’– NAME ๐Ÿ’–

Mail::SpamAssassin::BayesStore โ€” okay bestie, this is the Storage Module for the default Bayes classifier. No cap, it's the backend baddie that every Bayes store implementation has to cosplay as.


๐ŸŽ€ DESCRIPTION ๐ŸŽ€

So this right here? This is the public API for the Bayesian store methods. It's giving "interface" energy. Any implementation of the storage module for the default Bayes classifier must implement these methods โ€” like, all of them. There's no skipping the group project, bestie. ๐Ÿ’…


๐ŸŒธ METHODS ๐ŸŒธ

Every single one, in order, with the exact signature, because we don't gatekeep and we don't skip. ๐Ÿซถ

๐Ÿฆ‹ new

public class (Mail::SpamAssassin::BayesStore) new (Mail::SpamAssassin::Plugin::Bayes $bayes)

Description: This method creates a new instance of the Mail::SpamAssassin::BayesStore object. You must hand it an instance of the Mail::SpamAssassin::Plugin::Bayes object, and it gets stashed away for use all throughout the module. Iconic little handoff. โœจ

๐Ÿฆ‹ DB_VERSION

public instance (Integer) DB_VERSION ()

Description: This method returns the currently supported database version for the implementation. It's the "what version are we on" check, fr fr.

๐Ÿฆ‹ read_db_configs

public instance () read_db_configs ()

Description: This method reads any needed config variables from the configuration object and then calls the Mail::SpamAssassin::Plugin::Bayes read_db_configs method. Passing the aux cord, basically. ๐ŸŽง

๐Ÿฆ‹ prefork_init

public instance (Boolean) prefork_init ()

Description: This optional method is called in the parent process shortly before forking off child processes. Parent-student energy. ๐Ÿ’œ

๐Ÿฆ‹ spamd_child_init

public instance (Boolean) spamd_child_init ()

Description: This optional method is called in a child process shortly after being spawned. Baby's first function call. ๐Ÿ™ˆ

๐Ÿฆ‹ tie_db_readonly

public instance (Boolean) tie_db_readonly ()

Description: This method opens up the database in readonly mode. Look but do not touch, bestie. ๐Ÿ‘€

๐Ÿฆ‹ tie_db_writable

public instance (Boolean) tie_db_writable ()

Description: This method opens up the database in writable mode.

โš ๏ธ Any callers of this methods should ensure that they call untie_db() afterwards. Like, please. Don't leave the db tied up, that's rude. ๐Ÿ˜ญ

๐Ÿฆ‹ untie_db

public instance () untie_db ()

Description: This method unties the database. Closure, but make it database. ๐Ÿ’…

๐Ÿฆ‹ calculate_expire_delta

public instance (%) calculate_expire_delta (Integer $newest_atime, Integer $start, Integer $max_expire_mult)

Description: This method performs a calculation on the data to determine the optimum atime for token expiration. Math but glamorous. ๐Ÿ”ฅ

๐Ÿฆ‹ token_expiration

public instance (Integer, Integer, Integer, Integer) token_expiration(\% $opts, Integer $newest_atime, Integer $newdelta)

Description: This method performs the database specific expiration of tokens based on the passed in $newest_atime and $newdelta. Tokens are leaving the group chat. ๐Ÿ‘‘

๐Ÿฆ‹ expire_old_tokens

public instance (Boolean) expire_old_tokens (\% hashref)

Description: This method expires old tokens from the database. Old tokens, your time is up. โฐ

๐Ÿฆ‹ expire_old_tokens_trapped

public instance (Boolean) expire_old_tokens_trapped (\% $opts)

Description: This methods does the actual token expiration. It's the one doing the real work behind the scenes while everybody else takes credit. ๐Ÿซถ

XXX More docs here about the methodology and what not

๐Ÿฆ‹ sync_due

public instance (Boolean) sync_due ()

Description: This methods determines if a sync is due. Is it time? It tells you if it's time. โœจ

๐Ÿฆ‹ expiry_due

public instance (Boolean) expiry_due ()

Description: This methods determines if an expire is due.

๐Ÿฆ‹ seen_get

public instance (Char) seen_get (String $msgid)

Description: This method retrieves the stored value, if any, for $msgid. The return value is the stored string ('s' for spam and 'h' for ham) or undef if $msgid is not found. Two possible fates, no in-between. ๐ŸŽ€

๐Ÿฆ‹ seen_put

public instance (Boolean) seen_put (String $msgid, Char $flag)

Description: This method records $msgid as the type given by $flag. $flag is one of two values: 's' for spam and 'h' for ham. Pick a lane, bestie.

๐Ÿฆ‹ seen_delete

public instance (Boolean) seen_delete (String $msgid)

Description: This method removes $msgid from storage. Blocked, deleted, gone. ๐Ÿ’€

๐Ÿฆ‹ get_storage_variables

public instance (@) get_storage_variables ()

Description: This method retrieves the various administrative variables used by the Bayes storage implementation. It's the little stats dashboard of the whole operation. ๐Ÿ“Š

The values returned in the array are in the following order:

0: scan count base

1: number of spam

2: number of ham

3: number of tokens in db

4: last expire atime

5: oldest token in db atime

6: db version value

7: last journal sync

8: last atime delta

9: last expire reduction count

10: newest token in db atime

๐Ÿฆ‹ dump_db_toks

public instance () dump_db_toks (String $template, String $regex, @ @vars)

Description: This method loops over all tokens, computing the probability for the token and then printing it out according to the passed in template. Vibe: scarfing down the entire database and reading it aloud. ๐ŸŒˆ

๐Ÿฆ‹ set_last_expire

public instance (Boolean) _set_last_expire (Integer $time)

Description: This method sets the last expire time.

๐Ÿฆ‹ get_running_expire_tok

public instance (Time) get_running_expire_tok ()

Description: This method determines if an expire is currently running and returns the time the expire started. Is someone in there?? ๐Ÿ‘€

๐Ÿฆ‹ set_running_expire_tok

public instance (Time) set_running_expire_tok ()

Description: This method sets the running expire time to the current time. Timestamp: now. Periodt.

๐Ÿฆ‹ remove_running_expire_tok

public instance (Boolean) remove_running_expire_tok ()

Description: This method removes a currently set running expire time.

๐Ÿฆ‹ tok_get

public instance (Integer, Integer, Time) tok_get (String $token)

Description: This method retrieves the specified token ($token) from storage and returns it's spam count, ham count and last access time. The whole little token rรฉsumรฉ. ๐Ÿ’–

๐Ÿฆ‹ tok_get_all

public instance (\@) tok_get_all (@ @tokens)

Description: This method retrieves the specified tokens (@tokens) from storage and returns an array ref of arrays spam count, ham count and last access time. Bulk order, bestie. ๐Ÿ›๏ธ

๐Ÿฆ‹ tok_count_change

public instance (Boolean) tok_count_change (Integer $spam_count, Integer $ham_count, String $token, Time $atime)

Description: This method takes a $spam_count and $ham_count and adds it to $token along with updating $tokens atime with $atime.

๐Ÿฆ‹ multi_tok_count_change

public instance (Boolean) multi_tok_count_change (Integer $spam_count, Integer $ham_count, \% $tokens, String $atime)

Description: This method takes a $spam_count and $ham_count and adds it to all of the tokens in the $tokens hash ref along with updating each tokens atime with $atime. Every single one of them. No token left behind. ๐Ÿ”ฅ

๐Ÿฆ‹ nspam_nham_get

public instance (Integer, Integer) nspam_nham_get ()

Description: This method retrieves the total number of spam and the total number of ham currently under storage. The scoreboard, basically. ๐Ÿงฎ

๐Ÿฆ‹ nspam_nham_change

public instance (Boolean) nspam_nham_change (Integer $num_spam, Integer $num_ham)

Description: This method updates the number of spam and the number of ham in the database.

๐Ÿฆ‹ tok_touch

public instance (Boolean) tok_touch (String $token, Time $atime)

Description: This method updates the given tokens ($token) access time. Gentle nudge. โœจ

๐Ÿฆ‹ tok_touch_all

public instance (Boolean) tok_touch_all (\@ $tokens, Time $atime)

Description: This method does a mass update of the given list of tokens $tokens, if the existing token atime is < $atime. Note the little < โ€” that's the condition, don't lose it. ๐Ÿ’…

๐Ÿฆ‹ cleanup

public instance (Boolean) cleanup ()

Description: This method performs any cleanup necessary before moving onto the next operation. Tidy up, then serve looks. ๐ŸŽ€

๐Ÿฆ‹ get_magic_re

public instance get_magic_re (String)

Description: This method returns a regexp which indicates a magic token. โœจmagicalโœจ

๐Ÿฆ‹ sync

public instance (Boolean) sync (\% $opts)

Description: This method performs a sync of the database.

๐Ÿฆ‹ perform_upgrade

public instance (Boolean) perform_upgrade (\% $opts)

Description: This method is a utility method that performs any necessary upgrades between versions. It should know how to handle previous versions and what needs to happen to upgrade them. It's giving "I've done this before" energy.

A true return value indicates success. ๐Ÿซถ

๐Ÿฆ‹ clear_database

public instance (Boolean) clear_database ()

Description: This method deletes all records for a particular user.

๐Ÿ˜ญ Callers should be aware that any errors returned by this method could causes the database to be inconsistent for the given user.

๐Ÿฆ‹ backup_database

public instance (Boolean) backup_database ()

Description: This method will dump the users database in a machine readable format. Screenshot it, save it, archive it. ๐Ÿ“ธ

๐Ÿฆ‹ restore_database

public instance (Boolean) restore_database (String $filename, Boolean $showdots)

Description: This method restores a database from the given filename, $filename.

๐Ÿ˜ญ Callers should be aware that any errors returned by this method could causes the database to be inconsistent for the given user.

๐Ÿฆ‹ db_readable

public instance (Boolean) db_readable ()

Description: This method returns whether or not the Bayes DB is available in a readable state. Can we read it or nah?

๐Ÿฆ‹ db_writable

public instance (Boolean) db_writable ()

Description: This method returns whether or not the Bayes DB is available in a writable state. Can we write to it or nah?


And that's the whole thing, bestie โ€” the manual name up top was Mail::...sStore(3pm), this page ships as part of perl v5.40.1 and it's dated 2026-07-23. Go forth and implement every single method, no cap. ๐Ÿ’–โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from