Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
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/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea -...
16
 
-
 
17
/**
16
 
18
 * APCu cache store main library.
-
 
19
 *
17
use core_cache\configurable_cache_interface;
20
 * @package    cachestore_apcu
18
use core_cache\definition;
21
 * @copyright  2012 Sam Hemelryk
-
 
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
23
 */
-
 
24
 
19
use core_cache\key_aware_cache_interface;
Línea 25... Línea 20...
25
defined('MOODLE_INTERNAL') || die();
20
use core_cache\store;
26
 
21
 
27
/**
22
/**
-
 
23
 * The APCu cache store class.
28
 * The APCu cache store class.
24
 *
29
 *
25
 * @package    cachestore_apcu
30
 * @copyright  2012 Sam Hemelryk
26
 * @copyright  2012 Sam Hemelryk
31
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 */
-
 
33
class cachestore_apcu extends cache_store implements cache_is_key_aware, cache_is_configurable {
28
 */
34
 
29
class cachestore_apcu extends store implements configurable_cache_interface, key_aware_cache_interface {
35
    /**
30
    /**
36
     * The required version of APCu for this extension.
31
     * The required version of APCu for this extension.
Línea 43... Línea 38...
43
     */
38
     */
44
    protected $name;
39
    protected $name;
Línea 45... Línea 40...
45
 
40
 
46
    /**
41
    /**
47
     * The definition used when this instance was initialised.
42
     * The definition used when this instance was initialised.
48
     * @var cache_definition
43
     * @var definition
49
     */
44
     */
Línea 50... Línea 45...
50
    protected $definition = null;
45
    protected $definition = null;
51
 
46
 
Línea 79... Línea 74...
79
    }
74
    }
Línea 80... Línea 75...
80
 
75
 
81
    /**
76
    /**
82
     * Static method to check if a store is usable with the given mode.
77
     * Static method to check if a store is usable with the given mode.
83
     *
78
     *
84
     * @param int $mode One of cache_store::MODE_*
79
     * @param int $mode One of store::MODE_*
85
     * @return bool True if the mode is supported.
80
     * @return bool True if the mode is supported.
86
     */
81
     */
87
    public static function is_supported_mode($mode) {
82
    public static function is_supported_mode($mode) {
88
        return ($mode === self::MODE_APPLICATION || $mode === self::MODE_SESSION);
83
        return ($mode === self::MODE_APPLICATION || $mode === self::MODE_SESSION);
Línea 136... Línea 131...
136
    /**
131
    /**
137
     * Initialises a new instance of the cache store given the definition the instance is to be used for.
132
     * Initialises a new instance of the cache store given the definition the instance is to be used for.
138
     *
133
     *
139
     * This function should prepare any given connections etc.
134
     * This function should prepare any given connections etc.
140
     *
135
     *
141
     * @param cache_definition $definition
136
     * @param definition $definition
142
     * @return bool
137
     * @return bool
143
     */
138
     */
144
    public function initialise(cache_definition $definition) {
139
    public function initialise(definition $definition) {
145
        $this->definition = $definition;
140
        $this->definition = $definition;
146
        $this->cacheprefix = $this->storeprefix.$definition->generate_definition_hash().'__';
141
        $this->cacheprefix = $this->storeprefix.$definition->generate_definition_hash().'__';
147
        return true;
142
        return true;
148
    }
143
    }
Línea 301... Línea 296...
301
    /**
296
    /**
302
     * Generates an instance of the cache store that can be used for testing.
297
     * Generates an instance of the cache store that can be used for testing.
303
     *
298
     *
304
     * Returns an instance of the cache store, or false if one cannot be created.
299
     * Returns an instance of the cache store, or false if one cannot be created.
305
     *
300
     *
306
     * @param cache_definition $definition
301
     * @param definition $definition
307
     * @return cache_store
302
     * @return store
308
     */
303
     */
309
    public static function initialise_test_instance(cache_definition $definition) {
304
    public static function initialise_test_instance(definition $definition) {
310
        $testperformance = get_config('cachestore_apcu', 'testperformance');
305
        $testperformance = get_config('cachestore_apcu', 'testperformance');
311
        if (empty($testperformance)) {
306
        if (empty($testperformance)) {
312
            return false;
307
            return false;
313
        }
308
        }
314
        if (!self::are_requirements_met()) {
309
        if (!self::are_requirements_met()) {