Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-59118

Redis cachestore does not purge caches that do not have a definition

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.2, 3.3
    • Fix Version/s: None
    • Component/s: Caching
    • Labels:
      None
    • Affected Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE

      Description

      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

      https://docs.moodle.org/dev/Cache_API#Ad-hoc_Caches

      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/

      to reproduce:

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                devinefran Francis Devine
                Participants:
                Component watchers:
                Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: