Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
/**
18
 * Core cache definitions.
19
 *
20
 * This file is part of Moodle's cache API, affectionately called MUC.
21
 * It contains the components that are requried in order to use caching.
22
 *
23
 * @package    core
24
 * @category   cache
25
 * @copyright  2012 Sam Hemelryk
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
28
 
29
$definitions = array(
30
 
31
    // Used to store processed lang files.
32
    // The keys used are the revision, lang and component of the string file.
33
    // The static acceleration size has been based upon student access of the site.
34
    'string' => array(
35
        'mode' => cache_store::MODE_APPLICATION,
36
        'simplekeys' => true,
37
        'simpledata' => true,
38
        'staticacceleration' => true,
39
        'staticaccelerationsize' => 30,
40
        'canuselocalstore' => true,
41
    ),
42
 
43
    // Used to store cache of all available translations.
44
    'langmenu' => array(
45
        'mode' => cache_store::MODE_APPLICATION,
46
        'simplekeys' => true,
47
        'simpledata' => true,
48
        'staticacceleration' => true,
49
        'canuselocalstore' => true,
50
    ),
51
 
52
    // Used to store database meta information.
53
    // The database meta information includes information about tables and there columns.
54
    // Its keys are the table names.
55
    // When creating an instance of this definition you must provide the database family that is being used.
56
    'databasemeta' => array(
57
        'mode' => cache_store::MODE_APPLICATION,
58
        'requireidentifiers' => array(
59
            'dbfamily'
60
        ),
61
        'simpledata' => true, // This is a read only class, so leaving references in place is safe.
62
        'staticacceleration' => true,
63
        'staticaccelerationsize' => 15
64
    ),
65
 
66
    // Event invalidation cache.
67
    // This cache is used to manage event invalidation, its keys are the event names.
68
    // Whenever something is invalidated it is both purged immediately and an event record created with the timestamp.
69
    // When a new cache is initialised all timestamps are looked at and if past data is once more invalidated.
70
    // Data guarantee is required in order to ensure invalidation always occurs.
71
    // Persistence has been turned on as normally events are used for frequently used caches and this event invalidation
72
    // cache will likely be used either lots or never.
73
    'eventinvalidation' => array(
74
        'mode' => cache_store::MODE_APPLICATION,
75
        'staticacceleration' => true,
76
        'requiredataguarantee' => true,
77
        'simpledata' => true,
78
    ),
79
 
80
    // Hook callbacks cache.
81
    // There is a static cache in hook manager, data is fetched once per page on first hook execution.
82
    // This cache needs to be invalidated during upgrades when code changes and when callbacks
83
    // overrides are updated.
84
    'hookcallbacks' => array(
85
        'mode' => cache_store::MODE_APPLICATION,
86
        'simplekeys' => true,
87
        'simpledata' => true,
88
        'staticacceleration' => false,
89
        // WARNING: Manual cache purge may be required when overriding hook callbacks.
90
        'canuselocalstore' => true,
91
    ),
92
 
93
    // Cache for question definitions. This is used by the question_bank class.
94
    // Users probably do not need to know about this cache. They will just call
95
    // question_bank::load_question.
96
    'questiondata' => array(
97
        'mode' => cache_store::MODE_APPLICATION,
98
        'simplekeys' => true, // The id of the question is used.
99
        'requiredataguarantee' => false,
100
        'datasource' => 'question_finder',
101
        'datasourcefile' => 'question/engine/bank.php',
102
    ),
103
 
104
    // HTML Purifier cache
105
    // This caches the html purifier cleaned text. This is done because the text is usually cleaned once for every user
106
    // and context combo. Text caching handles caching for the combination, this cache is responsible for caching the
107
    // cleaned text which is shareable.
108
    'htmlpurifier' => array(
109
        'mode' => cache_store::MODE_APPLICATION,
110
        'canuselocalstore' => true,
111
    ),
112
 
113
    // Used to store data from the config + config_plugins table in the database.
114
    // The key used is the component:
115
    //   - core for all core config settings
116
    //   - plugin component for all plugin settings.
117
    // Persistence is used because normally several settings within a script.
118
    'config' => array(
119
        'mode' => cache_store::MODE_APPLICATION,
120
        'staticacceleration' => true,
121
        'simpledata' => true
122
    ),
123
 
124
    // Groupings belonging to a course.
125
    // A simple cache designed to replace $GROUPLIB_CACHE->groupings.
126
    // Items are organised by course id and are essentially course records.
127
    'groupdata' => array(
128
        'mode' => cache_store::MODE_APPLICATION,
129
        'simplekeys' => true, // The course id the groupings exist for.
130
        'simpledata' => true, // Array of stdClass objects containing only strings.
131
        'staticacceleration' => true, // Likely there will be a couple of calls to this.
132
        'staticaccelerationsize' => 2, // The original cache used 1, we've increased that to two.
133
    ),
134
 
135
    // Whether a course currently has hidden groups.
136
    'coursehiddengroups' => array(
137
        'mode' => cache_store::MODE_APPLICATION,
138
        'simplekeys' => true, // The course id the groupings exist for.
139
        'simpledata' => true, // Booleans.
140
        'staticacceleration' => true, // Likely there will be a couple of calls to this.
141
    ),
142
 
143
    // Used to cache calendar subscriptions.
144
    'calendar_subscriptions' => array(
145
        'mode' => cache_store::MODE_APPLICATION,
146
        'simplekeys' => true,
147
        'simpledata' => true,
148
        'staticacceleration' => true,
149
    ),
150
 
151
    // Cache the course categories where the user has any enrolment and all categories that this user can manage.
152
    'calendar_categories' => array(
153
        'mode' => cache_store::MODE_SESSION,
154
        'simplekeys' => true,
155
        'simpledata' => true,
156
        'invalidationevents' => array(
157
            'changesincoursecat',
158
            'changesincategoryenrolment',
159
        ),
160
        'ttl' => 900,
161
    ),
162
 
163
    // Cache the capabilities list DB table. See get_all_capabilities and get_deprecated_capability_info in accesslib.
164
    'capabilities' => array(
165
        'mode' => cache_store::MODE_APPLICATION,
166
        'simplekeys' => true,
167
        'simpledata' => true,
168
        'staticacceleration' => true,
169
        'staticaccelerationsize' => 2, // Should be main capabilities and deprecated capabilities.
170
        'ttl' => 3600, // Just in case.
171
    ),
172
 
173
    // YUI Module cache.
174
    // This stores the YUI module metadata for Shifted YUI modules in Moodle.
175
    'yuimodules' => array(
176
        'mode' => cache_store::MODE_APPLICATION,
177
    ),
178
 
179
    // Cache for the list of event observers.
180
    'observers' => array(
181
        'mode' => cache_store::MODE_APPLICATION,
182
        'simplekeys' => true,
183
        'simpledata' => true,
184
        'staticacceleration' => true,
185
        'staticaccelerationsize' => 2,
186
    ),
187
 
188
    // Cache used by the {@link core_plugin_manager} class.
189
    // NOTE: this must be a shared cache.
190
    'plugin_manager' => array(
191
        'mode' => cache_store::MODE_APPLICATION,
192
        'simplekeys' => true,
193
        'simpledata' => true,
194
    ),
195
 
196
    // Used to store the full tree of course categories.
197
    'coursecattree' => array(
198
        'mode' => cache_store::MODE_APPLICATION,
199
        'staticacceleration' => true,
200
        'invalidationevents' => array(
201
            'changesincoursecat',
202
        )
203
    ),
204
    // Used to store data for course categories visible to current user. Helps to browse list of categories.
205
    'coursecat' => array(
206
        'mode' => cache_store::MODE_SESSION,
207
        'invalidationevents' => array(
208
            'changesincoursecat',
209
            'changesincourse',
210
        ),
211
        'ttl' => 600,
212
    ),
213
    // Used to store data for course categories visible to current user. Helps to browse list of categories.
214
    'coursecatrecords' => array(
215
        'mode' => cache_store::MODE_REQUEST,
216
        'simplekeys' => true,
217
        'invalidationevents' => array(
218
            'changesincoursecat',
219
        ),
220
    ),
221
    // Used to store state of sections in course (collapsed or not).
222
    'coursesectionspreferences' => [
223
        'mode' => cache_store::MODE_REQUEST,
224
        'simplekeys' => true,
225
        'simpledata' => false,
226
        'staticacceleration' => true,
227
    ],
228
    // Cache course contacts for the courses.
229
    'coursecontacts' => array(
230
        'mode' => cache_store::MODE_APPLICATION,
231
        'staticacceleration' => true,
232
        'simplekeys' => true,
233
        'ttl' => 3600,
234
    ),
235
    // Course reactive state cache.
236
    'courseeditorstate' => [
237
        'mode' => cache_store::MODE_SESSION,
238
        'simplekeys' => true,
239
        'simpledata' => true,
240
    ],
241
    // Course actions instances cache.
242
    'courseactionsinstances' => [
243
        'mode' => cache_store::MODE_REQUEST,
244
        'simplekeys' => true,
245
        'simpledata' => false,
246
        'staticacceleration' => true,
247
        // Executing actions in more than 10 courses usually means executing the same action on each course
248
        // so there is no need for caching individual course instances.
249
        'staticaccelerationsize' => 10,
250
    ],
251
    // Used to store data for repositories to avoid repetitive DB queries within one request.
252
    'repositories' => array(
253
        'mode' => cache_store::MODE_REQUEST,
254
    ),
255
    // Used to store external badges.
256
    'externalbadges' => array(
257
        'mode' => cache_store::MODE_APPLICATION,
258
        'simplekeys' => true,
259
        'ttl' => 3600,
260
    ),
261
    // Accumulated information about course modules and sections used to print course view page (user-independent).
262
    // Used in functions:
263
    // - course_modinfo::build_course_section_cache()
264
    // - course_modinfo::inner_build_course_cache()
265
    // - get_array_of_activities()
266
    // Reset/update in functions:
267
    // - rebuild_course_cache()
268
    // - course_modinfo::purge_module_cache()
269
    // - course_modinfo::purge_section_cache()
270
    // - remove_course_contents().
271
    'coursemodinfo' => array(
272
        'mode' => cache_store::MODE_APPLICATION,
273
        'simplekeys' => true,
274
        'canuselocalstore' => true,
275
        'requirelockingbeforewrite' => true
276
    ),
277
    // This is the session user selections cache.
278
    // It's a special cache that is used to record user selections that should persist for the lifetime of the session.
279
    // Things such as which categories the user has expanded can be stored here.
280
    // It uses simple keys and simple data, please ensure all uses conform to those two constraints.
281
    'userselections' => array(
282
        'mode' => cache_store::MODE_SESSION,
283
        'simplekeys' => true,
284
        'simpledata' => true
285
    ),
286
 
287
    // Used to cache activity completion status.
288
    'completion' => array(
289
        'mode' => cache_store::MODE_APPLICATION,
290
        'simplekeys' => true,
291
        'simpledata' => true,
292
        'ttl' => 3600,
293
        'staticacceleration' => true,
294
        'staticaccelerationsize' => 2, // Should be current course and site course.
295
    ),
296
 
297
    // Used to cache course completion status.
298
    'coursecompletion' => array(
299
        'mode' => cache_store::MODE_APPLICATION,
300
        'simplekeys' => true,
301
        'simpledata' => true,
302
        'ttl' => 3600,
303
        'staticacceleration' => true,
304
        'staticaccelerationsize' => 30, // Will be users list of current courses in nav.
305
    ),
306
 
307
    // A simple cache that stores whether a user can expand a course in the navigation.
308
    // The key is the course ID and the value will either be 1 or 0 (cast to bool).
309
    // The cache isn't always up to date, it should only ever be used to save a costly call to
310
    // can_access_course on the first page request a user makes.
311
    'navigation_expandcourse' => array(
312
        'mode' => cache_store::MODE_SESSION,
313
        'simplekeys' => true,
314
        'simpledata' => true
315
    ),
316
 
317
    // Caches suspended userids by course.
318
    // The key is the courseid, the value is an array of user ids.
319
    'suspended_userids' => array(
320
        'mode' => cache_store::MODE_REQUEST,
321
        'simplekeys' => true,
322
        'simpledata' => true,
323
    ),
324
 
325
    // Cache system-wide role definitions.
326
    'roledefs' => array(
327
        'mode' => cache_store::MODE_APPLICATION,
328
        'simplekeys' => true,
329
        'simpledata' => true,
330
        'staticacceleration' => true,
331
        'staticaccelerationsize' => 30,
332
    ),
333
 
334
    // Caches plugins existing functions by function name and file.
335
    // Set static acceleration size to 5 to load a few functions.
336
    'plugin_functions' => array(
337
        'mode' => cache_store::MODE_APPLICATION,
338
        'simplekeys' => true,
339
        'simpledata' => true,
340
        'canuselocalstore' => true,
341
        'staticacceleration' => true,
342
        'staticaccelerationsize' => 5
343
    ),
344
 
345
    // Caches data about tag collections and areas.
346
    'tags' => array(
347
        'mode' => cache_store::MODE_REQUEST,
348
        'simplekeys' => true,
349
        'staticacceleration' => true,
350
    ),
351
 
352
    // Grade categories. Stored at session level as invalidation is very aggressive.
353
    'grade_categories' => array(
354
        'mode' => cache_store::MODE_SESSION,
355
        'simplekeys' => true,
356
        'invalidationevents' => array(
357
            'changesingradecategories',
358
        )
359
    ),
360
 
361
    // Store temporary tables information.
362
    'temp_tables' => array(
363
        'mode' => cache_store::MODE_REQUEST,
364
        'simplekeys' => true,
365
        'simpledata' => true
366
    ),
367
 
368
    // Caches tag index builder results.
369
    'tagindexbuilder' => array(
370
        'mode' => cache_store::MODE_SESSION,
371
        'simplekeys' => true,
372
        'simplevalues' => true,
373
        'staticacceleration' => true,
374
        'staticaccelerationsize' => 10,
375
        'ttl' => 900, // 15 minutes.
376
        'invalidationevents' => array(
377
            'resettagindexbuilder',
378
        ),
379
    ),
380
 
381
    // Caches contexts with insights.
382
    'contextwithinsights' => array(
383
        'mode' => cache_store::MODE_APPLICATION,
384
        'simplekeys' => true,
385
        'simpledata' => true,
386
        'staticacceleration' => true,
387
        'staticaccelerationsize' => 1
388
    ),
389
 
390
    // Caches message processors.
391
    'message_processors_enabled' => array(
392
        'mode' => cache_store::MODE_APPLICATION,
393
        'simplekeys' => true,
394
        'simpledata' => true,
395
        'staticacceleration' => true,
396
        'staticaccelerationsize' => 3
397
    ),
398
 
399
    // Caches the time of the last message in a conversation.
400
    'message_time_last_message_between_users' => array(
401
        'mode' => cache_store::MODE_APPLICATION,
402
        'simplekeys' => true, // The conversation id is used.
403
        'simplevalues' => true,
404
        'datasource' => '\core_message\time_last_message_between_users',
405
    ),
406
 
407
    // Caches font awesome icons.
408
    'fontawesomeiconmapping' => array(
409
        'mode' => cache_store::MODE_APPLICATION,
410
        'simplekeys' => true,
411
        'simpledata' => true,
412
        'staticacceleration' => true,
413
        'staticaccelerationsize' => 1
414
    ),
415
 
416
    // Caches processed CSS.
417
    'postprocessedcss' => array(
418
        'mode' => cache_store::MODE_APPLICATION,
419
        'simplekeys' => true,
420
        'simpledata' => true,
421
        'staticacceleration' => false,
422
    ),
423
 
424
    // Caches grouping and group ids of a user.
425
    'user_group_groupings' => array(
426
        'mode' => cache_store::MODE_APPLICATION,
427
        'simplekeys' => true,
428
        'simpledata' => true,
429
        'staticacceleration' => true,
430
    ),
431
 
432
    // This is the user's pre sign-up session cache.
433
    // This cache is used to record the user's pre sign-up data such as
434
    // age of digital consent (minor) status, accepted policies, etc.
435
    'presignup' => array(
436
        'mode' => cache_store::MODE_SESSION,
437
        'simplekeys' => true,
438
        'simpledata' => true,
439
        'ttl' => 1800
440
    ),
441
 
442
    // Caches the first time we analysed models' analysables.
443
    'modelfirstanalyses' => array(
444
        'mode' => cache_store::MODE_REQUEST,
445
        'simplekeys' => true,
446
        'simpledata' => true,
447
    ),
448
 
449
    // Cache the list of portfolio instances for the logged in user
450
    // in the portfolio_add_button constructor to avoid loading the
451
    // same data multiple times.
452
    'portfolio_add_button_portfolio_instances' => [
453
        'mode' => cache_store::MODE_REQUEST,
454
        'simplekeys' => true,
455
        'staticacceleration' => true
456
    ],
457
 
458
    // Cache the user dates for courses set to relative dates mode.
459
    'course_user_dates' => [
460
        'mode' => cache_store::MODE_REQUEST,
461
        'simplekeys' => true,
462
        'simpledata' => true,
463
        'staticacceleration' => true
464
    ],
465
 
466
    // Information generated during the calculation of indicators.
467
    'calculablesinfo' => [
468
        'mode' => cache_store::MODE_REQUEST,
469
        'simplekeys' => false,
470
        'simpledata' => false,
471
    ],
472
 
473
    // The list of content items (activities, resources and their subtypes) that can be added to a course for a user.
474
    'user_course_content_items' => [
475
        'mode' => cache_store::MODE_REQUEST,
476
        'simplekeys' => true,
477
    ],
478
 
479
    // The list of favourited content items (activities, resources and their subtypes) for a user.
480
    'user_favourite_course_content_items' => [
481
        'mode' => cache_store::MODE_APPLICATION,
482
        'simplekeys' => true,
483
    ],
484
 
485
    \core_course\local\service\content_item_service::RECOMMENDATION_CACHE => [
486
        'mode' => cache_store::MODE_APPLICATION,
487
        'simplekeys' => true,
488
    ],
489
 
490
    // Caches contentbank extensions management.
491
    'contentbank_enabled_extensions' => [
492
        'mode' => cache_store::MODE_APPLICATION,
493
        'simplekeys' => true,
494
        'simpledata' => true,
495
        'staticacceleration' => true,
496
    ],
497
    'contentbank_context_extensions' => [
498
        'mode' => cache_store::MODE_REQUEST,
499
        'simplekeys' => true,
500
        'simpledata' => true,
501
        'staticacceleration' => true,
502
    ],
503
 
504
    // Language strings for H5P content-type libraries.
505
    // Key "{$libraryname}/{$language}"" contains translations for a given library and language.
506
    // Key "$libraryname" has a list of all of the available languages for the library.
507
    'h5p_content_type_translations' => [
508
        'mode' => cache_store::MODE_APPLICATION,
509
        'simpledata' => true,
510
    ],
511
 
512
    // File cache for H5P Library ids.
513
    'h5p_libraries' => [
514
        'mode' => cache_store::MODE_APPLICATION,
515
        'simplekeys' => true,
516
        'canuselocalstore' => true
517
    ],
518
 
519
    // File cache for H5P Library files.
520
    'h5p_library_files' => [
521
        'mode' => cache_store::MODE_APPLICATION,
522
        'simplekeys' => true,
523
        'canuselocalstore' => true
524
    ],
525
 
526
    // Cache the grade letters for faster retrival.
527
    'grade_letters' => [
528
        'mode'                   => cache_store::MODE_REQUEST,
529
        'simplekeys'             => true,
530
        'staticacceleration'     => true,
531
        'staticaccelerationsize' => 100
532
    ],
533
 
534
    // Cache for licenses.
535
    'license' => [
536
        'mode' => cache_store::MODE_APPLICATION,
537
        'simplekeys' => true,
538
        'simpledata' => false,
539
    ],
540
 
541
    // Cache the grade setting for faster retrieval.
542
    'gradesetting' => [
543
        'mode'                   => cache_store::MODE_REQUEST,
544
        'simplekeys'             => true,
545
        'staticacceleration'     => true,
546
        'staticaccelerationsize' => 100
547
    ],
548
 
549
    // Course image cache.
550
    'course_image' => [
551
        'mode' => cache_store::MODE_APPLICATION,
552
        'simplekeys' => true,
553
        'simpledata' => true,
554
        'staticacceleration' => true,
555
        'datasource' => '\core_course\cache\course_image',
556
    ],
557
 
558
    // Cache the course categories where the user has access the content bank.
559
    'contentbank_allowed_categories' => [
560
        'mode' => cache_store::MODE_SESSION,
561
        'simplekeys' => true,
562
        'simpledata' => true,
563
        'invalidationevents' => [
564
            'changesincoursecat',
565
            'changesincategoryenrolment',
566
        ],
567
    ],
568
 
569
    // Cache the courses where the user has access the content bank.
570
    'contentbank_allowed_courses' => [
571
        'mode' => cache_store::MODE_SESSION,
572
        'simplekeys' => true,
573
        'simpledata' => true,
574
        'invalidationevents' => [
575
            'changesincoursecat',
576
            'changesincategoryenrolment',
577
            'changesincourse',
578
        ],
579
    ],
580
 
581
    // Users allowed reports according to audience.
582
    'reportbuilder_allowed_reports' => [
583
        'mode' => cache_store::MODE_APPLICATION,
584
        'simplekeys' => true,
585
        'simpledata' => true,
586
        'staticacceleration' => true,
587
        'ttl' => 1800,
588
    ],
589
 
590
    // Cache image dimensions.
591
    'file_imageinfo' => [
592
        'mode' => cache_store::MODE_APPLICATION,
593
        'simplekeys' => true,
594
        'simpledata' => true,
595
        'staticacceleration' => true,
596
        'canuselocalstore' => true,
597
        'staticaccelerationsize' => 100,
598
    ],
599
 
600
    // Cache if a user has the capability to share to MoodleNet.
601
    'moodlenet_usercanshare' => [
602
        'mode' => cache_store::MODE_SESSION,
603
        'simplekeys' => true,
604
        'simpledata' => true,
605
        'ttl' => 1800,
606
        'invalidationevents' => [
607
            'changesincoursecat',
608
            'changesincategoryenrolment',
609
            'changesincourse',
610
        ],
611
    ],
612
 
613
    // A theme has been used in context to override the default theme.
614
    // Applies to user, cohort, category and course.
615
    'theme_usedincontext' => [
616
        'mode' => cache_store::MODE_APPLICATION,
617
        'simplekeys' => true,
618
        'simpledata' => true,
619
        'staticacceleration' => true,
620
    ],
621
);