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 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

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: 596 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