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.

Differences Between: [Versions 311 and 402] [Versions 311 and 403]

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

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

Defines 1 class


Class: cache_config  - X-Ref

Cache configuration reader.

This class is used to interact with the cache's configuration.
The configuration is stored in the Moodle data directory.

__construct()   X-Ref
Please use cache_config::instance to get an instance of the cache config that is ready to be used.


instance()   X-Ref
Gets an instance of the cache_configuration class.

return: cache_config

config_file_exists()   X-Ref
Checks if the configuration file exists.

return: bool True if it exists

get_config_file_path()   X-Ref
Returns the expected path to the configuration file.

return: string The absolute path

load($configuration = false)   X-Ref
Loads the configuration file and parses its contents into the expected structure.

param: array|false $configuration Can be used to force a configuration. Should only be used when truly required.
return: boolean

get_site_identifier()   X-Ref
Returns the site identifier used by the cache API.

return: string

include_configuration()   X-Ref
Includes the configuration file and makes sure it contains the expected bits.

You need to ensure that the config file exists before this is called.

return: array

sort_mappings(array $a, array $b)   X-Ref
Used to sort cache config arrays based upon a sort key.

Highest number at the top.

param: array $a
param: array $b
return: int

get_definition_by_id($id)   X-Ref
Gets a definition from the config given its name.

param: string $id
return: bool

get_definitions()   X-Ref
Returns all the known definitions.

return: array

get_definitions_by_store($storename)   X-Ref
Returns the definitions mapped into the given store name.

param: string $storename
return: array Associative array of definitions, id=>definition

get_stores($mode, $requirements = 0)   X-Ref
Returns all of the stores that are suitable for the given mode and requirements.

param: int $mode One of cache_store::MODE_*
param: int $requirements The requirements of the cache as a binary flag
return: array An array of suitable stores.

get_stores_for_definition(cache_definition $definition)   X-Ref
Gets all of the stores that are to be used for the given definition.

param: cache_definition $definition
return: array

get_all_stores()   X-Ref
Returns all of the configured stores

return: array

get_mode_mappings()   X-Ref
Returns all of the configured mode mappings

return: array

get_definition_mappings()   X-Ref
Returns all of the known definition mappings.

return: array

get_locks()   X-Ref
Returns an array of the configured locks.

return: array Array of name => config

get_lock_for_store($storename)   X-Ref
Returns the lock store configuration to use with a given store.

param: string $storename
return: array

get_default_lock()   X-Ref
Gets the default lock instance.

return: array