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\store;
28
 
31
 
Línea 29... Línea 32...
29
defined('MOODLE_INTERNAL') || die();
32
defined('MOODLE_INTERNAL') || die();
30
 
33
 
31
/**
34
/**
32
 * The static data store class
35
 * The static data store class
33
 *
36
 *
34
 * @copyright  2012 Sam Hemelryk
37
 * @copyright  2012 Sam Hemelryk
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
-
 
37
abstract class static_data_store extends cache_store {
39
 */
38
 
40
abstract class static_data_store extends store {
39
    /**
41
    /**
40
     * An array for storage.
42
     * An array for storage.
41
     * @var array
43
     * @var array
Línea 132... Línea 134...
132
 
134
 
133
    /**
135
    /**
134
     * Constructs the store instance.
136
     * Constructs the store instance.
135
     *
137
     *
136
     * 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.
137
     * 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.
138
     *
140
     *
139
     * @param string $name
141
     * @param string $name
140
     * @param array $configuration
142
     * @param array $configuration
141
     */
143
     */
Línea 188... Línea 190...
188
    }
190
    }
Línea 189... Línea 191...
189
 
191
 
190
    /**
192
    /**
191
     * Returns true if the given mode is supported by this store.
193
     * Returns true if the given mode is supported by this store.
192
     *
194
     *
193
     * @param int $mode One of cache_store::MODE_*
195
     * @param int $mode One of store::MODE_*
194
     * @return bool
196
     * @return bool
195
     */
197
     */
196
    public static function is_supported_mode($mode) {
198
    public static function is_supported_mode($mode) {
197
        return ($mode === self::MODE_REQUEST);
199
        return ($mode === store::MODE_REQUEST);
Línea 198... Línea 200...
198
    }
200
    }
199
 
201
 
200
    /**
202
    /**
201
     * Initialises the cache.
203
     * Initialises the cache.
202
     *
204
     *
203
     * Once this has been done the cache is all set to be used.
205
     * Once this has been done the cache is all set to be used.
204
     *
206
     *
205
     * @param cache_definition $definition
207
     * @param definition $definition
206
     */
208
     */
207
    public function initialise(cache_definition $definition) {
209
    public function initialise(definition $definition) {
208
        $keyarray = $definition->generate_multi_key_parts();
210
        $keyarray = $definition->generate_multi_key_parts();
209
        $this->storeid = $keyarray['mode'].'/'.$keyarray['component'].'/'.$keyarray['area'].'/'.$keyarray['siteidentifier'];
211
        $this->storeid = $keyarray['mode'].'/'.$keyarray['component'].'/'.$keyarray['area'].'/'.$keyarray['siteidentifier'];
210
        $this->store = &self::register_store_id($this->storeid);
212
        $this->store = &self::register_store_id($this->storeid);
Línea 523... Línea 525...
523
    }
525
    }
Línea 524... Línea 526...
524
 
526
 
525
    /**
527
    /**
526
     * Generates an instance of the cache store that can be used for testing.
528
     * Generates an instance of the cache store that can be used for testing.
527
     *
529
     *
528
     * @param cache_definition $definition
530
     * @param definition $definition
529
     * @return cachestore_static
531
     * @return cachestore_static
530
     */
532
     */
531
    public static function initialise_test_instance(cache_definition $definition) {
533
    public static function initialise_test_instance(definition $definition) {
532
        // Do something here perhaps.
534
        // Do something here perhaps.
533
        $cache = new cachestore_static('Static store');
535
        $cache = new cachestore_static('Static store');
534
        $cache->initialise($definition);
536
        $cache->initialise($definition);
535
        return $cache;
537
        return $cache;