Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 24... Línea 24...
24
 * @category   cache
24
 * @category   cache
25
 * @copyright  2012 Sam Hemelryk
25
 * @copyright  2012 Sam Hemelryk
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
27
 */
Línea -... Línea 28...
-
 
28
 
-
 
29
use core_cache\definition;
-
 
30
use core_cache\key_aware_cache_interface;
-
 
31
use core_cache\searchable_cache_interface;
-
 
32
use core_cache\store;
28
 
33
 
Línea 29... Línea 34...
29
defined('MOODLE_INTERNAL') || die();
34
defined('MOODLE_INTERNAL') || die();
30
 
35
 
31
/**
36
/**
32
 * The session data store class.
37
 * The session data store class.
33
 *
38
 *
34
 * @copyright  2012 Sam Hemelryk
39
 * @copyright  2012 Sam Hemelryk
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Línea 36... Línea 41...
36
 */
41
 */
37
abstract class session_data_store extends cache_store {
42
abstract class session_data_store extends store {
38
 
43
 
39
    /**
44
    /**
Línea 88... Línea 93...
88
 * The Session store class.
93
 * The Session store class.
89
 *
94
 *
90
 * @copyright  2012 Sam Hemelryk
95
 * @copyright  2012 Sam Hemelryk
91
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
96
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
92
 */
97
 */
93
class cachestore_session extends session_data_store implements cache_is_key_aware, cache_is_searchable {
98
class cachestore_session extends session_data_store implements key_aware_cache_interface, searchable_cache_interface {
94
 
-
 
95
    /**
99
    /**
96
     * The name of the store
100
     * The name of the store
97
     * @var store
101
     * @var store
98
     */
102
     */
99
    protected $name;
103
    protected $name;
Línea 130... Línea 134...
130
 
134
 
131
    /**
135
    /**
132
     * Constructs the store instance.
136
     * Constructs the store instance.
133
     *
137
     *
134
     * Noting that this function is not an initialisation. It is used to prepare the store for use.
138
     * Noting that this function is not an initialisation. It is used to prepare the store for use.
135
     * The store will be initialised when required and will be provided with a cache_definition at that time.
139
     * The store will be initialised when required and will be provided with a definition at that time.
136
     *
140
     *
137
     * @param string $name
141
     * @param string $name
138
     * @param array $configuration
142
     * @param array $configuration
139
     */
143
     */
Línea 184... Línea 188...
184
    }
188
    }
Línea 185... Línea 189...
185
 
189
 
186
    /**
190
    /**
187
     * Returns true if the given mode is supported by this store.
191
     * Returns true if the given mode is supported by this store.
188
     *
192
     *
189
     * @param int $mode One of cache_store::MODE_*
193
     * @param int $mode One of store::MODE_*
190
     * @return bool
194
     * @return bool
191
     */
195
     */
192
    public static function is_supported_mode($mode) {
196
    public static function is_supported_mode($mode) {
193
        return ($mode === self::MODE_SESSION);
197
        return ($mode === store::MODE_SESSION);
Línea 194... Línea 198...
194
    }
198
    }
195
 
199
 
196
    /**
200
    /**
197
     * Initialises the cache.
201
     * Initialises the cache.
198
     *
202
     *
199
     * Once this has been done the cache is all set to be used.
203
     * Once this has been done the cache is all set to be used.
200
     *
204
     *
201
     * @param cache_definition $definition
205
     * @param definition $definition
202
     */
206
     */
203
    public function initialise(cache_definition $definition) {
207
    public function initialise(definition $definition) {
204
        $this->storeid = $definition->generate_definition_hash();
208
        $this->storeid = $definition->generate_definition_hash();
205
        $this->store = &self::register_store_id($this->name.'-'.$definition->get_id());
209
        $this->store = &self::register_store_id($this->name.'-'.$definition->get_id());
206
        $this->ttl = $definition->get_ttl();
210
        $this->ttl = $definition->get_ttl();
Línea 504... Línea 508...
504
    }
508
    }
Línea 505... Línea 509...
505
 
509
 
506
    /**
510
    /**
507
     * Generates an instance of the cache store that can be used for testing.
511
     * Generates an instance of the cache store that can be used for testing.
508
     *
512
     *
509
     * @param cache_definition $definition
513
     * @param definition $definition
510
     * @return cachestore_session
514
     * @return cachestore_session
511
     */
515
     */
512
    public static function initialise_test_instance(cache_definition $definition) {
516
    public static function initialise_test_instance(definition $definition) {
513
        // Do something here perhaps.
517
        // Do something here perhaps.
514
        $cache = new cachestore_session('Session test');
518
        $cache = new cachestore_session('Session test');
515
        $cache->initialise($definition);
519
        $cache->initialise($definition);
516
        return $cache;
520
        return $cache;