Affects Version/s: 3.2, 3.3
Fix Version/s: None
Affected Branches:MOODLE_32_STABLE, MOODLE_33_STABLE
The Redis cachestore added in Moodle 3.2 does not appear to clear any cache that is setup on an adhoc basis, which is something that is possible with the cache API
No matter if you use the purgeall caches admin option, or the purge caches cli script, cached values stored in an ad hoc created cache will never be purged.
I have created a test block that indicates the problem, you can download it from https://seafile.catalyst.net.nz/f/f9e7034a5d/
1) Setup a moodle 3.3 site
2) Configure and enable Redis as the default application cache
3) Install the test block and add it to dashboard or course page, it will display no cache value is set
4) run test.php from the cli to set the cache value and refresh the page to confirm
5) attempt to purge the cache via cli or via the admin options and observe that the string remains in the cache
6) move the caches.bak file to caches.php and bump the version number and upgrade the site - observe that the cache no longer has the string stored
7) Run test.php and refresh page to confirm the cached value is back
8) purge caches via cli or admin options and confirm the cache is properly cleared
This issue doesn't arise with the other cachestore plugins as most of them purge all records for a given instance when asked to purge the caches, i.e Redis is the only one correctly purging only the things it is asked to purge.
I'm not 100% sure that this is a bug however, as it's possible that adhoc caches were never intended to be cleared, but if so that should be included in the documentation that these are not meant to be cleared by any of the standard cache purges.
An argument could be made to do away with the ability to add adhoc caches at all and just always require a definition given how trivial it is to add them, with the make function erroring if the cache is not defined. This sidesteps the confusion completely and makes life easier on those who are implementing cachestores, since they can be sure of all the caches that are defined and available.