Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
cache_data_source Interface Reference

Cache Data Source. More...

Inheritance diagram for cache_data_source:
cache_data_source_versionable core_course\cache\course_image core_message\time_last_message_between_users mod_assign\cache\overrides mod_lesson\cache\overrides mod_quiz\cache\overrides mod_scorm\cache\elements question_finder

Public Member Functions

 load_for_cache ($key)
 Loads the data for the key provided ready formatted for caching.
 
 load_many_for_cache (array $keys)
 Loads several keys for the cache.
 

Static Public Member Functions

static get_instance_for_cache (cache_definition $definition)
 Returns an instance of the data source class that the cache can use for loading data using the other methods specified by this interface.
 

Detailed Description

Cache Data Source.

The cache data source interface can be implemented by any class within Moodle. If implemented then the class can be reference in a cache definition and will be used to load information that cannot be retrieved from the cache. As part of its retrieval that information will also be loaded into the cache.

This allows developers to created a complete cache solution that can be used through code ensuring consistent cache interaction and loading. Allowing them in turn to centralise code and help keeps things more easily maintainable.

Can be implemented by any class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ get_instance_for_cache()

static cache_data_source::get_instance_for_cache ( cache_definition $definition)
static

Returns an instance of the data source class that the cache can use for loading data using the other methods specified by this interface.

Parameters
cache_definition$definition
Return values
object

Implemented in core_course\cache\course_image, mod_assign\cache\overrides, mod_lesson\cache\overrides, mod_quiz\cache\overrides, mod_scorm\cache\elements, and question_finder.

◆ load_for_cache()

cache_data_source::load_for_cache ( $key)

Loads the data for the key provided ready formatted for caching.

Parameters
string | int$keyThe key to load.
Return values
mixedWhat ever data should be returned, or false if it can't be loaded.

Implemented in core_course\cache\course_image, core_message\time_last_message_between_users, mod_assign\cache\overrides, mod_lesson\cache\overrides, mod_quiz\cache\overrides, mod_scorm\cache\elements, and question_finder.

◆ load_many_for_cache()

cache_data_source::load_many_for_cache ( array $keys)

Loads several keys for the cache.

Parameters
array$keysAn array of keys each of which will be string|int.
Return values
arrayAn array of matching data items.

Implemented in core_course\cache\course_image, core_message\time_last_message_between_users, mod_assign\cache\overrides, mod_lesson\cache\overrides, mod_quiz\cache\overrides, mod_scorm\cache\elements, and question_finder.


The documentation for this interface was generated from the following file: