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

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



    • 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:


      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.


          Issue Links



              mr-russ Russell Smith
              mr-russ Russell Smith
              Component watchers:
              Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona), Matteo Scaramuccia, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              0 Vote for this issue
              6 Start watching this issue