Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Administration helper base class. More...
Public Member Functions | |
generate_admin_page (\core_cache\output\renderer $renderer) | |
This function must be implemented to display the cache admin page. | |
get_addable_lock_options () | |
This function must be implemented to get addable locks. | |
get_definition_actions (\context $context, array $definitionsummary) | |
This function must be implemented to display options for definition mappings. | |
get_store_instance_actions (string $name, array $storedetails) | |
This function must be implemented to display options for store instances. | |
get_store_plugin_actions (string $name, array $plugindetails) | |
This function must be implemented to display options for store plugins. | |
get_usage (int $samplekeys) | |
Gets usage information about the whole cache system. | |
perform_cache_actions (string $action, array $forminfo) | |
This function must be implemented to perform any page actions by a child class. | |
Static Public Member Functions | |
static | clean_old_session_data ($output=false) |
Cleans old session data from cache stores used for session based definitions. | |
static | cron () |
Runs cron routines for MUC. | |
static | early_get_cache_plugins () |
Returns an array of plugins without using core methods. | |
static | get_cache_stores (cache_definition $definition) |
Returns the cache stores to be used with the given definition. | |
static | get_cachelock_for_store (cache_store $store) |
Returns a cache_lock instance suitable for use with the store. | |
static | get_class_for_mode ($mode) |
Returns the class for use as a cache loader for the given mode. | |
static | get_default_mode_stores () |
Get the default stores for all modes. | |
static | get_definition_name ($definition) |
Returns the translated name of the definition. | |
static | get_definition_sharing_options (int $sharingoption, bool $isselectedoptions=true) |
Given a sharing option hash this function returns an array of strings that can be used to describe it. | |
static | get_definition_store_options (string $component, string $area) |
Get an array of stores that are suitable to be used for a given definition. | |
static | get_definition_summaries () |
Returns an array about the definitions. | |
static | get_lock_summaries () |
Returns an array summarising the locks available in the system. | |
static | get_site_identifier () |
Returns the site identifier. | |
static | get_site_version () |
Returns the site version. | |
static | get_stats () |
Return the stats collected so far. | |
static | get_store_instance_summaries () |
Returns an array containing all of the information about stores a renderer needs. | |
static | get_store_plugin_summaries () |
Returns an array of information about plugins, everything a renderer needs. | |
static | get_stores_suitable_for_definition (cache_definition $definition) |
Returns stores suitable for use with a given definition. | |
static | get_stores_suitable_for_mode_default () |
Returns an array of stores that would meet the requirements for every definition. | |
static | hash_key ($key, cache_definition $definition) |
Hashes a descriptive key to make it shorter and still unique. | |
static | invalidate_by_definition ($component, $area, array $identifiers=array(), $keys=array()) |
Invalidates a given set of keys from a given definition. | |
static | invalidate_by_event ($event, array $keys) |
Invalidates a given set of keys by means of an event. | |
static | is_cluster_available () |
Checks whether the cluster mode is available in PHP. | |
static | purge_all ($usewriter=false) |
Purge all of the cache stores of all of their data. | |
static | purge_by_definition ($component, $area, array $identifiers=array()) |
Purges the cache for a specific definition. | |
static | purge_by_event ($event) |
Purges a cache of all information on a given event. | |
static | purge_store ($storename, cache_config $config=null) |
Purges a store given its name. | |
static | purge_stores_used_by_definition ($component, $area) |
Purges all of the stores used by a definition. | |
static | ready_for_early_init () |
Returns true if the cache API can be initialised before Moodle has finished initialising itself. | |
static | record_cache_hit ($store, $definition, int $hits=1, int $readbytes=cache_store::IO_BYTES_NOT_SUPPORTED) |
Record a cache hit in the stats for the given store and definition. | |
static | record_cache_miss ($store, $definition, $misses=1) |
Record a cache miss in the stats for the given store and definition. | |
static | record_cache_set ($store, $definition, int $sets=1, int $writebytes=cache_store::IO_BYTES_NOT_SUPPORTED) |
Record a cache set in the stats for the given store and definition. | |
static | result_found ($value) |
A helper to determine whether a result was found. | |
static | update_definitions ($coreonly=false) |
Finds all definitions and updates them within the cache config file. | |
static | update_site_identifier ($siteidentifier) |
Update the site identifier stored by the cache API. | |
static | warnings (array $stores=null) |
Returns an array of warnings from the cache API. | |
Static Protected Member Functions | |
static | ensure_ready_for_stats ($store, $storeclass, $definition, $mode=cache_store::MODE_APPLICATION) |
Ensure that the stats array is ready to collect information for the given store and definition. | |
static | get_definition_stat_id_and_mode ($definition) |
Returns a string to describe the definition. | |
static | initialise_cachestore_instances (array $stores, cache_definition $definition) |
Internal function for initialising an array of stores against a given cache definition. | |
static | instance () |
Returns an instance of the cache_helper. | |
Static Protected Attributes | |
static cache_helper | $instance |
The instance of the cache helper. | |
static string | $siteidentifier = null |
The site identifier used by the cache. | |
static array | $stats = array() |
Statistics gathered by the cache API during its operation will be used here. | |
Administration helper base class.
Defines abstract methods for a subclass to define the admin page.
|
staticinherited |
Cleans old session data from cache stores used for session based definitions.
bool | $output | If set to true output will be given. |
|
staticinherited |
Returns an array of plugins without using core methods.
This function explicitly does NOT use core functions as it will in some circumstances be called before Moodle has finished initialising. This happens when loading configuration for instance.
array |
|
staticprotectedinherited |
Ensure that the stats array is ready to collect information for the given store and definition.
string | $store | |
string | $storeclass | |
string | $definition | A string that identifies the definition. |
int | $mode | One of cache_store\MODE_*. Since 2.9. |
|
abstract |
This function must be implemented to display the cache admin page.
core_cache\output\renderer | $renderer | the renderer used to generate the page. |
string | the HTML for the page. |
Reimplemented in core_cache\local\administration_display_helper.
core_cache\administration_helper::get_addable_lock_options | ( | ) |
This function must be implemented to get addable locks.
array | array of locks that are addable. |
Reimplemented in core_cache\local\administration_display_helper.
|
staticinherited |
Returns the cache stores to be used with the given definition.
cache_definition | $definition |
array |
|
staticinherited |
Returns a cache_lock instance suitable for use with the store.
cache_store | $store |
cache_lock_interface |
|
staticinherited |
Returns the class for use as a cache loader for the given mode.
int | $mode | One of cache_store\MODE_ |
string |
coding_exception |
|
static |
Get the default stores for all modes.
array | An array containing sub-arrays, one for each mode. |
core_cache\administration_helper::get_definition_actions | ( | \context | $context, |
array | $definitionsummary ) |
This function must be implemented to display options for definition mappings.
context | $context | the context for the definition. |
array | $definitionsummary | the definition summary. |
array | array of actions. |
Reimplemented in core_cache\local\administration_display_helper.
|
staticinherited |
Returns the translated name of the definition.
cache_definition | $definition |
lang_string |
|
static |
Given a sharing option hash this function returns an array of strings that can be used to describe it.
int | $sharingoption | The sharing option hash to get strings for. |
bool | $isselectedoptions | Set to true if the strings will be used to view the selected options. |
array | An array of lang_string's. |
|
staticprotectedinherited |
Returns a string to describe the definition.
This method supports the definition as a string due to legacy requirements. It is backwards compatible when a string is passed but is not accurate.
cache_definition | string | $definition |
string |
|
static |
Get an array of stores that are suitable to be used for a given definition.
string | $component | |
string | $area |
array | Array containing 3 elements
|
|
static |
Returns an array about the definitions.
All the information a renderer needs.
array | for each store, an array containing various information about each store. See the code below for details |
|
static |
Returns an array summarising the locks available in the system.
array | array of lock summaries. |
|
staticinherited |
Returns the site identifier.
string |
|
staticinherited |
Returns the site version.
string |
|
staticinherited |
Return the stats collected so far.
array |
core_cache\administration_helper::get_store_instance_actions | ( | string | $name, |
array | $storedetails ) |
This function must be implemented to display options for store instances.
string | $name | the store instance name. |
array | $storedetails | array of store instance details. |
array | array of actions. |
Reimplemented in core_cache\local\administration_display_helper.
|
static |
Returns an array containing all of the information about stores a renderer needs.
array |
core_cache\administration_helper::get_store_plugin_actions | ( | string | $name, |
array | $plugindetails ) |
This function must be implemented to display options for store plugins.
string | $name | the name of the store plugin. |
array | $plugindetails | array of store plugin details. |
array | array of actions. |
Reimplemented in core_cache\local\administration_display_helper.
|
static |
Returns an array of information about plugins, everything a renderer needs.
array | for each store, an array containing various information about each store. See the code below for details |
|
staticinherited |
Returns stores suitable for use with a given definition.
cache_definition | $definition |
cache_store[] |
|
staticinherited |
Returns an array of stores that would meet the requirements for every definition.
These stores would be 100% suitable to map as defaults for cache modes.
array[] | An array of stores, keys are the store names. |
|
abstract |
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:
The storetotal field will be the same for every cache that uses the same store.
int | $samplekeys | Number of keys to sample when checking size of large caches |
array | Details of cache usage |
Reimplemented in core_cache\local\administration_display_helper.
|
staticinherited |
Hashes a descriptive key to make it shorter and still unique.
string | int | $key | |
cache_definition | $definition |
string |
|
staticprotectedinherited |
Internal function for initialising an array of stores against a given cache definition.
array | $stores | |
cache_definition | $definition |
cache_store[] |
|
staticprotectedinherited |
Returns an instance of the cache_helper.
This is designed for internal use only and acts as a static store. @staticvar null $instance
cache_helper |
|
staticinherited |
Invalidates a given set of keys from a given definition.
string | $component | |
string | $area | |
array | $identifiers | |
array | string | int | $keys |
boolean |
coding_exception |
|
staticinherited |
Invalidates a given set of keys by means of an event.
Events cannot determine what identifiers might need to be cleared. Event based purge and invalidation are only supported on caches without identifiers.
string | $event | |
array | $keys |
|
staticinherited |
Checks whether the cluster mode is available in PHP.
bool | Return true if the PHP supports redis cluster, otherwise false. |
|
abstract |
This function must be implemented to perform any page actions by a child class.
string | $action | the action to perform. |
array | $forminfo | empty array to be set by actions. |
array | array of form info. |
Reimplemented in core_cache\local\administration_display_helper.
|
staticinherited |
Purge all of the cache stores of all of their data.
Think twice before calling this method. It will purge ALL caches regardless of whether they have been used recently or anything. This will involve full setup of the cache + the purge operation. On a site using caching heavily this WILL be painful.
bool | $usewriter | If set to true the cache_config_writer class is used. This class is special as it avoids it is still usable when caches have been disabled. Please use this option only if you really must. It's purpose is to allow the cache to be purged when it would be otherwise impossible. |
|
staticinherited |
Purges the cache for a specific definition.
string | $component | |
string | $area | |
array | $identifiers |
bool |
|
staticinherited |
Purges a cache of all information on a given event.
Events cannot determine what identifiers might need to be cleared. Event based purge and invalidation are only supported on caches without identifiers.
string | $event |
|
staticinherited |
|
staticinherited |
Purges all of the stores used by a definition.
Unlike cache_helper\purge_by_definition this purges all of the data from the stores not just the data relating to the definition. This function is useful when you must purge a definition that requires setup but you don't want to set it up.
string | $component | |
string | $area |
|
staticinherited |
Returns true if the cache API can be initialised before Moodle has finished initialising itself.
This check is essential when trying to cache the likes of configuration information. It checks to make sure that the cache configuration file has been created which allows use to set up caching when ever is required.
bool |
|
staticinherited |
Record a cache hit in the stats for the given store and definition.
In Moodle 2.9 the $definition argument changed from accepting only a string to accepting a string or a cache_definition instance. It is preferable to pass a cache definition instance.
In Moodle 3.9 the first argument changed to also accept a cache_store.
|
staticinherited |
Record a cache miss in the stats for the given store and definition.
In Moodle 2.9 the $definition argument changed from accepting only a string to accepting a string or a cache_definition instance. It is preferable to pass a cache definition instance.
In Moodle 3.9 the first argument changed to also accept a cache_store.
|
staticinherited |
Record a cache set in the stats for the given store and definition.
In Moodle 2.9 the $definition argument changed from accepting only a string to accepting a string or a cache_definition instance. It is preferable to pass a cache definition instance.
In Moodle 3.9 the first argument changed to also accept a cache_store.
|
staticinherited |
A helper to determine whether a result was found.
This has been deemed required after people have been confused by the fact that [] == false.
mixed | $value |
bool |
|
staticinherited |
Finds all definitions and updates them within the cache config file.
bool | $coreonly | If set to true only core definitions will be updated. |
|
staticinherited |
Update the site identifier stored by the cache API.
string | $siteidentifier |
string | The new site identifier. |
|
staticinherited |
Returns an array of warnings from the cache API.
The warning returned here are for things like conflicting store instance configurations etc. These get shown on the admin notifications page for example.
array | null | $stores | An array of stores to get warnings for, or null for all. |
string[] |
|
staticprotectedinherited |
The site identifier used by the cache.
Set the first time get_site_identifier is called.