Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
/cache/ -> locallib.php (source)

Differences Between: [Versions 39 and 311]

The supplementary cache API. This file is part of Moodle's cache API, affectionately called MUC. It contains elements of the API that are not required in order to use caching. Things in here are more in line with administration and management of the cache setup and configuration.

Copyright: 2012 Sam Hemelryk
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 674 lines (28 kb)
Included or required:0 times
Referenced: 11 times
Includes or requires: 0 files

Defines 1 class


Class: cache_config_writer  - X-Ref

Cache configuration writer.

This class should only be used when you need to write to the config, all read operations exist within the cache_config.

instance()   X-Ref
Returns an instance of the configuration writer.

return: cache_config_writer

config_save()   X-Ref
Saves the current configuration.

Exceptions within this function are tolerated but must be of type cache_exception.
They are caught during initialisation and written to the error log. This is required in order to avoid
infinite loop situations caused by the cache throwing exceptions during its initialisation.

generate_configuration_array()   X-Ref
Generates a configuration array suitable to be written to the config file.

return: array

add_store_instance($name, $plugin, array $configuration = array()   X-Ref
Adds a plugin instance.

This function also calls save so you should redirect immediately, or at least very shortly after
calling this method.

param: string $name The name for the instance (must be unique)
param: string $plugin The name of the plugin.
param: array $configuration The configuration data for the plugin instance.
return: bool

add_lock_instance($name, $plugin, $configuration = array()   X-Ref
Adds a new lock instance to the config file.

param: string $name The name the user gave the instance. PARAM_ALHPANUMEXT
param: string $plugin The plugin we are creating an instance of.
param: string $configuration Configuration data from the config instance.

delete_lock_instance($name)   X-Ref
Deletes a lock instance given its name.

param: string $name The name of the plugin, PARAM_ALPHANUMEXT.
return: bool

set_mode_mappings(array $modemappings)   X-Ref
Sets the mode mappings.

These determine the default caches for the different modes.
This function also calls save so you should redirect immediately, or at least very shortly after
calling this method.

param: array $modemappings
return: bool

edit_store_instance($name, $plugin, $configuration)   X-Ref
Edits a give plugin instance.

The plugin instance is determined by its name, hence you cannot rename plugins.
This function also calls save so you should redirect immediately, or at least very shortly after
calling this method.

param: string $name
param: string $plugin
param: array $configuration
return: bool

delete_store_instance($name)   X-Ref
Deletes a store instance.

This function also calls save so you should redirect immediately, or at least very shortly after
calling this method.

param: string $name The name of the instance to delete.
return: bool

create_default_configuration($forcesave = false)   X-Ref
Creates the default configuration and saves it.

This function calls config_save, however it is safe to continue using it afterwards as this function should only ever
be called when there is no configuration file already.

param: bool $forcesave If set to true then we will forcefully save the default configuration file.
return: true|array Returns true if the default configuration was successfully created.

get_default_stores()   X-Ref
Returns an array of default stores for use.

return: array

update_default_config_stores()   X-Ref
Updates the default stores within the MUC config file.


update_definitions($coreonly = false)   X-Ref
Updates the definition in the configuration from those found in the cache files.

Calls config_save further down, you should redirect immediately or asap after calling this method.

param: bool $coreonly If set to true only core definitions will be updated.

locate_definitions($coreonly = false)   X-Ref
Locates all of the definition files.

param: bool $coreonly If set to true only core definitions will be updated.
return: array

write_definitions_to_cache(array $definitions)   X-Ref
Writes the updated definitions for the config file.

param: array $definitions

load_caches_file($file)   X-Ref
Loads the caches file if it exists.

param: string $file Absolute path to the file.
return: array

set_definition_mappings($definition, $mappings)   X-Ref
Sets the mappings for a given definition.

param: string $definition
param: array $mappings

update_site_identifier($siteidentifier)   X-Ref
Update the site identifier stored by the cache API.

param: string $siteidentifier
return: string The new site identifier.

set_definition_sharing($definition, $sharingoption, $userinputsharingkey = null)   X-Ref
Sets the selected sharing options and key for a definition.

param: string $definition The name of the definition to set for.
param: int $sharingoption The sharing option to set.
param: string|null $userinputsharingkey The user input key or null.