Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | List of all members
cacheable_object Interface Reference

Cacheable object. More...

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

Public Member Functions

 prepare_to_cache ()
 Prepares the object for caching. More...
 

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. More...
 

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 repository, repository_type, and core_course_category.

◆ 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 repository, repository_type, and core_course_category.


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