Add logging of cache clearing

Created on 5 June 2024, 7 months ago
Updated 6 June 2024, 7 months ago

Problem/Motivation

We used this module to allow our communications team to "judiciously" clear caches. Some content creators might overuse the clearing of caches so we'd like to track who cleared the caches and how often and the logs seem like the best way to do that. Currently nothing is written to the log and there seems to be no way to track usage.

Proposed resolution

I'm going to attach the preliminary solution in a patch file, though it is years since I did this last so please forgive any errors. I also see that patch files are no longer the recommended approach, but in this case it serves to document my proposed change, which while it would work for me might need fleshing out by a module maintainer. In our case we're only using the Clear All option that works out of the box after installing the module. Since the two things that would seem to need tracking are that caches were cleared and by whom, the code in the patch grabs the current user and writes a dblog message, something like "Caches were cleared from the Cacheflush module by Grant." I only added it to the Clear All option, but it could be expanded. It does not affect the APIs, UI, models etc. I don't often write this sort of code so hopefully it's all done right.

Remaining tasks

Does this seem like something others would want? We think so, but it's your call. Then you might want to decide to make the log-writing code a function and call it from other cache clear functions, as you deem appropriate.

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States grantkruger Portland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024