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

Only allow MUC identifiers to be set as part of cache construction

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0.2
    • Fix Version/s: None
    • Component/s: Caching, Performance
    • Labels:
      None

      Description

      When a cache instance is created, it initially sets the cache identifiers.

      It is then possible to change the identifiers by using $cache->set_identifiers() function. This changes part of the cache instance to point to a different set of keys in the cache than it did before. However the cache instance is still considered the same. This means that it's impossible to cache a cache::make() result as it is not guaranteed to point to the same cache information that was set when cache::make() was called.

      The first example of this is in the databasemeta cache. It requires the dbfamily and settings to be set on each call. If you do the following, the actual result is probably not what's expected.

      $cachepg = cache::make('core', 'databasemeta', array('a' => 'pgsql'));
      $cachepg->set(1, 'here');
      $cachemy = cache::make('core', 'databasemeta', array('a' => 'mysql'));
      $result = $cachepg->get(2);
      $result will be false rather than 'here' as you might expect.
      

      This behaviour change proposes the following things;
      1. the set_identifiers() definition function will be made unavailable and only used in a cache constructor.
      2. The definition instance cache will now consider identifiers to be part of the same cache. So identifiers are considered completely different cache instances rather than the possibility of changing where a cache points to.
      3. All keys that are generated as part of the cache creation can be then cached in the correct location, reducing cache storage overhead. These are singlekeyprefix and multikeyprefix. They are used to split stores into different parts when multiple caches operate on them.

      The databasemeta cache will also be updated to use the ability to store a cache pointer inside the class for faster database lookups without calling cache::make on each call to get_columns.

      This change also allows for more broad caching of cache::make() with the assurance you will get the answers you will expect. This can save quite some time parsing any identifiers and returning the correct cache definition to the function.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mr-russ Russell Smith
                Reporter:
                mr-russ Russell Smith
                Peer reviewer:
                Eloy Lafuente (stronk7)
                Participants:
                Component watchers:
                Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Matteo Scaramuccia, Jake Dallimore, Jun Pataleta
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated: