Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
cacheable_object Interface Reference

Cacheable object. More...

Inheritance diagram for cacheable_object:

Public Member Functions

 prepare_to_cache ()
 Prepares the object for caching.
 

Static Public Member Functions

static wake_from_cache ($data)
 Takes the data provided by prepare_to_cache and reinitialises an instance of the associated from it.
 

Detailed Description

Cacheable object.

This interface can be implemented by any class that is going to be passed into a cache and allows it to take control of the structure and the information about to be cached, as well as how to deal with it when it is retrieved from a cache. Think of it like serialisation and the __sleep and __wakeup methods. This is used because cache stores are responsible for how they interact with data and what they do when storing it. This interface ensures there is always a guaranteed action.

Member Function Documentation

◆ prepare_to_cache()

cacheable_object::prepare_to_cache ( )

Prepares the object for caching.

Works like the __sleep method.

Return values
mixedThe data to cache, can be anything except a class that implements the cacheable_object... that would be dumb.

Implemented in core_course_category, repository, and repository_type.

◆ wake_from_cache()

static cacheable_object::wake_from_cache ( $data)
static

Takes the data provided by prepare_to_cache and reinitialises an instance of the associated from it.

Parameters
mixed$data
Return values
objectThe instance for the given data.

Implemented in core_course_category, repository, and repository_type.


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