Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
cacheable_object Interface Reference

Cacheable object. More...

Inheritance diagram for cacheable_object:
core_course_category repository repository_type repository_areafiles repository_contentbank repository_coursefiles repository_dropbox repository_equella repository_filesystem repository_flickr repository_flickr_public repository_local repository_merlot repository_nextcloud repository_onedrive repository_recent repository_s3 repository_upload repository_url repository_user repository_webdav repository_wikimedia repository_youtube

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: