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

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

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 3.0.2
    • Caching, Performance
    • None

      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.

            Unassigned Unassigned
            mr-russ Russell Smith
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.