Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 400 and 402]

Cache display administration helper. This file is part of Moodle's cache API, affectionately called MUC. It contains the components that are requried in order to use caching.

Author: Peter Burnett <peterburnett@catalyst-au.net>
Copyright: 2020 Catalyst IT
Copyright: 2012 Sam Hemelryk
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 889 lines (37 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: administration_display_helper  - X-Ref

A cache helper for administration tasks

__construct()   X-Ref
Please do not call constructor directly. Use cache_factory::get_administration_display_helper() instead.


get_definition_actions(\context $context, array $definitionsummary)   X-Ref
Returns all of the actions that can be performed on a definition.

param: context $context the system context.
param: array $definitionsummary information about this cache, from the array returned by
return: array of actions. Each action is an action_url.

get_store_instance_actions(string $name, array $storedetails)   X-Ref
Returns all of the actions that can be performed on a store.

param: string $name The name of the store
param: array $storedetails information about this store, from the array returned by
return: array of actions. Each action is an action_url.

get_store_plugin_actions(string $name, array $plugindetails)   X-Ref
Returns all of the actions that can be performed on a plugin.

param: string $name The name of the plugin
param: array $plugindetails information about this store, from the array returned by
return: array of actions. Each action is an action_url.

get_add_store_form(string $plugin)   X-Ref
Returns a form that can be used to add a store instance.

param: string $plugin The plugin to add an instance of
return: cachestore_addinstance_form

get_edit_store_form(string $plugin, string $store)   X-Ref
Returns a form that can be used to edit a store instance.

param: string $plugin
param: string $store
return: cachestore_addinstance_form

get_possible_locks_for_stores(string $plugindir, string $plugin)   X-Ref
Returns an array of suitable lock instances for use with this plugin, or false if the plugin handles locking itself.

param: string $plugindir
param: string $plugin
return: array|false

get_store_configuration_from_data(\stdClass $data)   X-Ref
Processes the results of the add/edit instance form data for a plugin returning an array of config information suitable to
store in configuration.

param: stdClass $data The mform data.
return: array

get_addable_lock_options()   X-Ref
Returns an array of lock plugins for which we can add an instance.

Suitable for use within an mform select element.

return: array

get_add_lock_form(string $plugin, array $lockplugin = null)   X-Ref
Gets the form to use when adding a lock instance.

param: string $plugin
param: array $lockplugin
return: cache_lock_form

get_lock_configuration_from_data(string $plugin, \stdClass $data)   X-Ref
Gets configuration data from a new lock instance form.

param: string $plugin
param: stdClass $data
return: array

perform_cache_actions(string $action, array $forminfo)   X-Ref
Handles the page actions, based on the parameter.

param: string $action the action to handle.
param: array $forminfo an empty array to be overridden and set.
return: array the empty or overridden forminfo array.

action_rescan_definition()   X-Ref
Performs the rescan definition action.

return: void

action_addstore()   X-Ref
Performs the add store action.

return: array an array of the form to display to the user, and the page title.

action_editstore()   X-Ref
Performs the edit store action.

return: array an array of the form to display, and the page title.

action_deletestore(string $action)   X-Ref
Performs the deletestore action.

param: string $action the action calling to this function.

action_editdefinitionmapping()   X-Ref
Performs the edit definition mapping action.

return: array an array of the form to display, and the page title.

action_editdefinitionsharing()   X-Ref
Performs the edit definition sharing action.

return: array an array of the edit definition sharing form, and the page title.

action_editmodemappings()   X-Ref
Performs the edit mode mappings action.

return: array an array of the edit mode mappings form.

action_purgedefinition()   X-Ref
Performs the purge definition action.

return: void

action_purge()   X-Ref
Performs the purge action.

return: void

action_newlockinstance()   X-Ref
Performs the new lock instance action.

return: array An array containing the new lock instance form.

action_deletelock(string $action)   X-Ref
Performs the delete lock action.

param: string $action the action calling this function.

generate_admin_page(\core_cache\output\renderer $renderer)   X-Ref
Outputs the main admin page by generating it through the renderer.

param: \core_cache\output\renderer $renderer the renderer to use to generate the page.
return: string the HTML for the admin page.

get_usage(int $samplekeys)   X-Ref
Gets usage information about the whole cache system.

This is a slow function and should only be used on an admin information page.

The returned array lists all cache definitions with fields 'cacheid' and 'stores'. For
each store, the following fields are available:

- name (store name)
- class (e.g. cachestore_redis)
- supported (true if we have any information)
- items (number of items stored)
- mean (mean size of item)
- sd (standard deviation for item sizes)
- margin (margin of error for mean at 95% confidence)
- storetotal (total usage for store if known, otherwise null)

The storetotal field will be the same for every cache that uses the same store.

param: int $samplekeys Number of keys to sample when checking size of large caches
return: array Details of cache usage