IMO this is plain wrong.
What happens when you encounter the same URL every day? It will never get updated. If the redirection has changed from the provider (for example it was detected as spam, and redirect removed etc), cache will never update to new URL if you see it every day. If you want to keep things longer on "hot cache", then increase TTL, it should be that simple. I don't want to get into commit war, so waiting for your comment. On Tue, May 03, 2022 at 12:39:04PM -0000, gbec...@apache.org wrote: > Author: gbechis > Date: Tue May 3 12:39:04 2022 > New Revision: 1900506 > > URL: http://svn.apache.org/viewvc?rev=1900506&view=rev > Log: > cleanup database by checking "modified" field so that frequently checked > urls are always in hot cache > > Modified: > spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm > > Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm > URL: > http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm?rev=1900506&r1=1900505&r2=1900506&view=diff > ============================================================================== > --- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm > (original) > +++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm Tue > May 3 12:39:04 2022 > @@ -286,7 +286,7 @@ See C<url_shortener_cache_autoclean> for > > =item url_shortener_cache_autoclean (default: 1000) > > -Automatically purge old entries from database. Value describes a random run > +Automatically purge old unused entries from database. Value describes a > random run > chance of 1/x. The default value of 1000 means that cleaning is run > approximately once for every 1000 messages processed. Value of 1 would mean > database is cleaned every time a message is processed. > @@ -395,11 +395,11 @@ sub initialise_url_shortener_cache { > "); > $self->{sth_delete} = $self->{dbh}->prepare(" > DELETE FROM short_url_cache > - WHERE short_url = ? AND created < strftime('%s','now') - > $conf->{url_shortener_cache_ttl} > + WHERE short_url = ? AND modified < strftime('%s','now') - > $conf->{url_shortener_cache_ttl} > "); > $self->{sth_clean} = $self->{dbh}->prepare(" > DELETE FROM short_url_cache > - WHERE created < strftime('%s','now') - > $conf->{url_shortener_cache_ttl} > + WHERE modified < strftime('%s','now') - > $conf->{url_shortener_cache_ttl} > "); > }; > } > @@ -432,11 +432,11 @@ sub initialise_url_shortener_cache { > "); > $self->{sth_delete} = $self->{dbh}->prepare(" > DELETE FROM short_url_cache > - WHERE short_url = ? AND created < UNIX_TIMESTAMP() - > $conf->{url_shortener_cache_ttl} > + WHERE short_url = ? AND modified < UNIX_TIMESTAMP() - > $conf->{url_shortener_cache_ttl} > "); > $self->{sth_clean} = $self->{dbh}->prepare(" > DELETE FROM short_url_cache > - WHERE created < UNIX_TIMESTAMP() - $conf->{url_shortener_cache_ttl} > + WHERE modified < UNIX_TIMESTAMP() - $conf->{url_shortener_cache_ttl} > "); > }; > } > @@ -469,11 +469,11 @@ sub initialise_url_shortener_cache { > "); > $self->{sth_delete} = $self->{dbh}->prepare(" > DELETE FROM short_url_cache > - WHERE short_url ? = AND created < CAST(EXTRACT(epoch FROM NOW()) AS > INT) - $conf->{url_shortener_cache_ttl} > + WHERE short_url ? = AND modified < CAST(EXTRACT(epoch FROM NOW()) AS > INT) - $conf->{url_shortener_cache_ttl} > "); > $self->{sth_clean} = $self->{dbh}->prepare(" > DELETE FROM short_url_cache > - WHERE created < CAST(EXTRACT(epoch FROM NOW()) AS INT) - > $conf->{url_shortener_cache_ttl} > + WHERE modified < CAST(EXTRACT(epoch FROM NOW()) AS INT) - > $conf->{url_shortener_cache_ttl} > "); > }; > ## >