On Thu, 2025-06-26 at 18:36 -0700, Mark Sapiro wrote:

> 
> You can delete the cached entry from the database via `mailman shell
> as in

>  >>> cm = getUtility(ICacheManager)
>  >>> uri = 'the_uri_from_the_template_table'
>  >>> cm.get(uri, expunge=True)
>  >>> commit()
> ```
> 
> You can also delete the entry from the file_cache table, but if you
> do 
> that, the actual file containing the cached data will remain. To
> remove 
> it, 
> 
> Rather than doing any of the above, if you want to manipulate the 
> database, just set the expires_on column in the file_cache table
> entry 
> to a date in the past.
> 

Hi Mark,

Thank you for this information. I've given the options a good workout
over the last couple of days and found that:

1. Deleting the cache via the mailman shell does the job, but is beyond
me to script. There are numerous lists and list owners updating their
templates.

2. Changing the expires_on date (to a date in the past) in the
file_cache table didn't prevent the cached entry from being used;

3. What did work was removing the records in the file_cache table PLUS
removing the corresponding files in var/cache/*/*/* -- for example:
/opt/mailman/mm/var/cache/3a/2f/*

This I was able to script in bash and cron to run every minute. 

A hack I know, but it's working for now. 

I've attached the script in case it's of use to anyone else.
(mailman_clear_template_cache.txt) Note: change <USER> in the script to
what suits.

Does Mailman really need to cache the templates? It seems to be an
unnecessary complication. 

Anyways it happy days again. Thank you again, very much. Your guidance
was appreciated immensely as always.

Best,
Mark




#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
rm /home/<USER>/cache_filepaths
sudo -Hiu mailman psql -d mailman -t -A -c "SELECT substring(file_id, 1, 4) as 
filepath FROM file_cache" > /home/<USER>/cache_filepaths
sed -i 's/./&\//2; s/$/\/\*/' cache_filepaths
cat /home/<USER>/cache_filepaths
for list in `cat /home/<USER>/cache_filepaths`
do
CACHE=$list
rm /opt/mailman/mm/var/cache/$CACHE
done
sudo -Hiu mailman psql -d mailman -t -A -c "DELETE FROM file_cache"
exit 0
_______________________________________________
Mailman-users mailing list -- mailman-users@mailman3.org
To unsubscribe send an email to mailman-users-le...@mailman3.org
https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/
Archived at: 
https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/QFZZHN4WWHSS63RQJDPZAGFO6OTDV35A/

This message sent to arch...@mail-archive.com

Reply via email to