Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace core_cache;
18
 
19
/**
20
 * Cacheable object.
21
 *
22
 * 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
23
 * structure and the information about to be cached, as well as how to deal with it when it is retrieved from a cache.
24
 * Think of it like serialisation and the __sleep and __wakeup methods.
25
 * This is used because cache stores are responsible for how they interact with data and what they do when storing it. This
26
 * interface ensures there is always a guaranteed action.
27
 *
28
 * @package core_cache
29
 * @copyright Sam Hemelryk
30
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 */
32
interface cacheable_object_interface {
33
    /**
34
     * Prepares the object for caching. Works like the __sleep method.
35
     *
36
     * @return mixed The data to cache, can be anything except a class that implements the cacheable_object... that would
37
     *      be dumb.
38
     */
39
    public function prepare_to_cache();
40
 
41
    /**
42
     * Takes the data provided by prepare_to_cache and reinitialises an instance of the associated from it.
43
     *
44
     * @param mixed $data
45
     * @return object The instance for the given data.
46
     */
47
    public static function wake_from_cache($data);
48
}
49
 
50
// Alias this class to the old name.
51
// This file will be autoloaded by the legacyclasses autoload system.
52
// In future all uses of this class will be corrected and the legacy references will be removed.
53
class_alias(cacheable_object_interface::class, \cacheable_object::class);